How to setup Google analytics on AMP wordpress plugin?

 

It is super easy to setup google analytics on the AMP wordpress plugin.

It is very important to remember that AMP pages cannot contain javascript code. Aim for speed.

  1. Install the AMP plugin
  2. Setup theme, page and logo
  3. Suppress all plugins for speed
  4. Install the analytics code

You can install the code in your plugin.

Copy and paste the following code

{
"vars": {
"account": "UA-xxxxxx-x"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}

Note: You must enter the Type: googleanalytics. If you leave it blank, analytics tracking will not work.

After this you will see pages with ?amp=1 will appear

More information on how to add code to your AMP pages is available here