Title: Adding Google Analytics
Last modified: March 29, 2018

---

# Adding Google Analytics

 *  Resolved [davekehoe84](https://wordpress.org/support/users/davekehoe84/)
 * (@davekehoe84)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/)
 * I am trying to add Google Analytics to the AMP plugin.
 * I have seen several guides online, but I have an issue in that the AMP Analytics
   Options on the plugin in the backend of wordpress, the ID field does not allow
   me to type or paste anything.
 * I have deleted and re-installed the plugin, but still not able to add details
   to the ID field.
 * Does anyone have a solution to this issue?
 * Any help would be appreciated.

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

 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10139124)
 * The ID is read-only and dynamically generated. You shouldn’t be manually putting
   anything into it. Why are you trying to modify it?
 *  Thread Starter [davekehoe84](https://wordpress.org/support/users/davekehoe84/)
 * (@davekehoe84)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10141882)
 * Hi Weston,
 * Thanks for your response. I am wanting to add Google Analytics to my AMP pages
   and posts.
 * So I thought I must add the analytics code and ID into this section… ?
 * What am I doing wrong?
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10142349)
 * [@davekehoe84](https://wordpress.org/support/users/davekehoe84/) have you followed
   the instructions at [https://github.com/Automattic/amp-wp/wiki/Analytics](https://github.com/Automattic/amp-wp/wiki/Analytics)?
 *  Thread Starter [davekehoe84](https://wordpress.org/support/users/davekehoe84/)
 * (@davekehoe84)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10145843)
 * Hi Weston,
 * Thanks for your guidance.
 * I have followed these instructions, added googleanalytics to the type field, 
   left the ID field blank and added my google analytics tracking code to the JSON
   Configuration field.
 * However, it gives a message of Invalid analytics config JSON.
 * What must I do to convert my tracking code into the correct format?
 * I appreciate your help, could you advise me further or point me in the direction
   of a guide to do so.
 * Best wishes
 * Dave
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10146379)
 * You’ll need to share the JSON code you entered here for us to be able to help.
 *  [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/)
 * (@ryankienstra)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10146380)
 * Hi [@davekehoe84](https://wordpress.org/support/users/davekehoe84/),
    Thanks 
   for letting us know how this went.
 * Does what you added to the “JSON Configuration” field look something like the
   JSON inside the `<script type="application/json">` here?
 * [https://developers.google.com/analytics/devguides/collection/amp-analytics/#page_tracking](https://developers.google.com/analytics/devguides/collection/amp-analytics/#page_tracking)
    -  This reply was modified 8 years, 1 month ago by [Ryan Kienstra](https://wordpress.org/support/users/ryankienstra/).
 *  Thread Starter [davekehoe84](https://wordpress.org/support/users/davekehoe84/)
 * (@davekehoe84)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10148791)
 * Is there a way I can give you this code privately?
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10150462)
 * Why? It will be displayed publicly on your site anyway.
 *  Thread Starter [davekehoe84](https://wordpress.org/support/users/davekehoe84/)
 * (@davekehoe84)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10152730)
 * Ok,
 * This is the tracking code I get from Google Analytics, which I am trying to add
   to the AMP plugin.
 * <!– Global site tag (gtag.js) – Google Analytics –>
    <script async src=”[https://www.googletagmanager.com/gtag/js?id=UA-42994922-6″></script&gt](https://www.googletagmanager.com/gtag/js?id=UA-42994922-6″></script&gt);
   <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.
   push(arguments);} gtag(‘js’, new Date());
 *  gtag(‘config’, ‘UA-42994922-6’);
    </script>
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10154608)
 * OK, you’re pasting in the non-AMP Google Analytics JavaScript code. You need 
   to paste in the AMP JSON code. It should look something like this for you:
 *     ```
       {
         "vars": {
           "account": "UA-42994922-6"
         },
         "triggers": {
           "trackPageview": {
             "on": "visible",
             "request": "pageview"
           }
         }
       }
       ```
   
 * Refer to the docs for configuration: [https://developers.google.com/analytics/devguides/collection/amp-analytics/](https://developers.google.com/analytics/devguides/collection/amp-analytics/)
 *  Thread Starter [davekehoe84](https://wordpress.org/support/users/davekehoe84/)
 * (@davekehoe84)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10161456)
 * Thank you Weston, that code has been accepted by the plugin so I think the analytics
   should start working now.
 * I must admit, I am very confused by this setup. No-where in any docs could I 
   find simple instructions as to what to do, so thanks again for helping me.
 * Exactly what will this code offer data on then in analytics?
 * Is it just page views? Or behaviours? Referrals? Etc
 * Does a separate piece of code need to be added for each event?
 * I appreciate you helping me get this setup.
 * Best wishes
 * Dave Kehoe
 *  Plugin Author [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * (@westonruter)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10163035)
 * [@davekehoe84](https://wordpress.org/support/users/davekehoe84/) I’m not an analytics
   expert myself, but you can see from the Google Analytics docs what kinds of things
   that can track: [https://developers.google.com/analytics/devguides/collection/amp-analytics/](https://developers.google.com/analytics/devguides/collection/amp-analytics/)
 * Otherwise, I suggest inquiring of the Google Analytics support forums to get 
   more details.

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

The topic ‘Adding Google Analytics’ 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/)

 * 12 replies
 * 3 participants
 * Last reply from: [Weston Ruter](https://wordpress.org/support/users/westonruter/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/adding-google-analytics-8/#post-10163035)
 * Status: resolved