• Resolved funkoolow

    (@funkoolow)


    hello,
    I’m trying to add some code in the <head> section of a website for tracking purposes, acting as specified in documentation

    thus, i’ve added this code in the functions.php theme file:

    	<script async src="https://cdn.ampproject.org/v0.js"></script>
    	<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
    	<amp-analytics type="nielsen">
        <script type="application/json">
        {
          "vars": {
            "apid": "F328C33C-5747-49C1-8F59-A396D28389B2",
            "prefix": "eu-",
            "apv": "1.0",
            "apn": "FIRSTonline Website",
            "section": "FIRSTonline_AMP",
            "segA": "NA",
            "segB": "NA",
            "segC": "Google AMP"
          }
        }
        </script>
    </amp-analytics>
    

    once done, looking at the resulting page, some parts of the code are filtered (the two <script> tags to include src files are missing) and the remaining code is postponed AFTER the closing </head> tag (which is not good for my desired result).

    It seems that something interferes reworking my code, but since no particular plugin is installed for such action, i’m wondering if i’m missing something or doing it completely wrong somehow…

    I’ve also tried with the amp subfolder in the theme folder approach (copying the plugins/amp/templates/html-start.php file under the themes/mytheme/amp dir and editing it as needed with the code originally included in the functions.php file), obtaining more or less the same result.

    Eventually, can someone suggest some alternative way to directly add the code I need in the <head> section?

    plugin version is 2.1.3
    wp version is 5.7.2

    thanks in advance for any help!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @funkoolow

    Thank you for the support topic,
    You don’t need to add the AMP runtime script and AMP analytics script.

    <script async src="https://cdn.ampproject.org/v0.js"></script>
    <script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>

    The AMP plugin detects and components being used on the page adds the required scripts for them.

    I will recommend using the AMP Plugins Analytics Options to add the nielsen analytics.

    Step 1: goto -> AMP -> Analytics
    Step 2: Click Big plus ( + ) button
    Step 3: Enter type as “nielsen”
    Step 4: Add the config json in text area.
    Step 5: Save

    • This reply was modified 3 years, 4 months ago by Milind More.

    @funkoolow As we haven’t received a response, I’ll mark this as resolved. Feel free to open a new support topic if you continue to encounter issues, or reopen this topic and we’d be happy to assist. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘adding code in section not working’ is closed to new replies.