Title: adding code in section not working
Last modified: July 30, 2021

---

# adding code in section not working

 *  Resolved [funkoolow](https://wordpress.org/support/users/funkoolow/)
 * (@funkoolow)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/adding-code-in-section-not-working/)
 * hello,
    I’m trying to add some code in the <head> section of a website for tracking
   purposes, acting as specified [in documentation](https://amp-wp.org/documentation/playbooks/classic-templates/)
 * 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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fadding-code-in-section-not-working%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/adding-code-in-section-not-working/#post-14719236)
 * Hello [@funkoolow](https://wordpress.org/support/users/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
 * ![](https://i0.wp.com/i.prntscr.com/jBaAhSTzQEKeZxXdcCpK0g.png)
    -  This reply was modified 4 years, 10 months ago by [Milind More](https://wordpress.org/support/users/milindmore22/).
 *  [Bethany Chobanian Lang](https://wordpress.org/support/users/mxbclang/)
 * (@mxbclang)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/adding-code-in-section-not-working/#post-14743225)
 * [@funkoolow](https://wordpress.org/support/users/funkoolow/) As we haven’t received
   a response, I’ll mark this as resolved. Feel free to open a [new support topic](https://wordpress.org/support/plugin/amp/#new-post)
   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.

 * ![](https://ps.w.org/amp/assets/icon.svg?rev=2527602)
 * [AMP](https://wordpress.org/plugins/amp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amp/)
 * [Active Topics](https://wordpress.org/support/plugin/amp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amp/reviews/)

## Tags

 * [head](https://wordpress.org/support/topic-tag/head/)

 * 2 replies
 * 3 participants
 * Last reply from: [Bethany Chobanian Lang](https://wordpress.org/support/users/mxbclang/)
 * Last activity: [4 years, 10 months ago](https://wordpress.org/support/topic/adding-code-in-section-not-working/#post-14743225)
 * Status: resolved