Hello,
I’m using AMP pages for my blog and observe that Google Analytics doesn’t count the traffic came to the AMP pages. Traffic to non AMP pages is counted and showing correctly. I put the same GA tracking script in AMP section of Theme Panel but doesn’t work.
Please guide me how to put the GA tracking code for amp pages in Newspaper theme, I video tutorial will be much helpful as I don’t know much about coding and WordPress.
Thanks!
Umar
Hi,
The analytics code for AMP should be of this form only, please check it
– https://www.screencast.com/t/xL301xKgf
If you enter it like that it will be loaded in AMP pages.
From what I can find online, maybe it would be better to use different tracking for AMP
– https://moz.com/blog/amp-reporting
Thanks
Thanks for the reply, How to generate this code? and where need to place it in Newspaper theme to properly work?
It would be the same configuration as mentioned here
– https://developers.google.com/analytics/devguides/collection/amp-analytics/
Use your analytics ID and enter the code as mentioned in the theme panel amp section
– https://www.screencast.com/t/xVhGQqG5m
Simion, I’ve placed this code in the AMP analytics section but not sure it’s working. Is this correct (I’ve deleted some of the ID numbers for security here)
I got the code from the Google Developers link you posted.
Thanks!
<script async custom-element=”amp-analytics” src=”https://cdn.ampproject.org/v0/amp-analytics-0.1.js”></script>
<amp-analytics type=”gtag” data-credentials=”include”>
<script type=”application/json”>
{
“vars” : {
“gtag_id”: “<UA-5947****-1>”,
“config” : {
“<UA-5947****-1>”: { “groups”: “default” }
}
}
}
</script>
</amp-analytics>
That is an example of the analytics code, enter it like this – http://prntscr.com/lw1r40
Then check in the page source of an AMP post – http://prntscr.com/lw1sj1
The code should be present in the source, the theme will add the necessary tags and load it for all amp content.
