Google Analytic Tracking Code in Json Format for AMP Pages Tracking in WordPress

Hi, if you recently added a plugin like Automattic or Glue for Yoast SEO and AMP then you should add Google analytic code to track your AMP pages. There is an option in Automattic AMP plugin and in Glue for Yoast SEO plugin to add Google analytic tracking code in JSON format for AMP pages tracking in WordPress.

But if you will add javascript analytic code then it will not work and even Yoast plugin will not save the changes. Because it requires in JSON format. So Below is the Google analytic code in JSON format. Copy and paste below code in the Yoast analytic or in Automattic analytic page. Before paste change UA-XXXXXX with your Google Analytic track ID.

<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXXX" 
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>

Leave a Comment