Install Glue For Yoast SEO & AMP plugin.
Not only does this plugin gives you the ability to add GA tracking to your AMPs, but it also enables you to customize the look of your accelerated mobile pages, at least to some extent.
As soon as you install the plugin, navigate to its settings and click on the ‘Analytics’ tab.
Please note: generic GA scripts will not work with the AMP framework, so you will have to add an AMP-specific JSON version of your GA script.
Simply add the following lines to the tracking field in Yoast Glue AMP analytics. Ensure to replace a default tracking ID with your unique ID.
“account”: “UA-XXXXX-Y” – Replace this with your tracking code
It’s worth noting that this method may not work for everyone. To troubleshoot your GA installation using this approach, open up one of your accelerated mobile pages, navigate to Google Analytics and check real-time sessions. If you see live traffic, your GA script has been installed correctly.
Otherwise, if you don’t see any live sessions, it’s likely that this method hasn’t worked for you. In this case, you will need to follow the method below.
Read more –