Google Analytics with AMP

Recep Baltaş

Well-known member
Any idea on where and how to add analytics code to an AMP page?

e.g.:

Code:
https://www.technopat.net/sosyal/konu/macos-sierra-10-12-4-vmware-iso.431768/?amp=1
 
Are you using bdCache ? If so , you can use Xenforo's google analytics function in statics page.
If you are not ;
add this between head tags ;

<script async custom-element="amp-analytics"
src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
and add this in the end of the AMP style thread view ;
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXX-Y"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>

Don't forget to change the ID.
 
Thank you. Although I have updated my AMP plugin, it still did not work...

So, I have added the code to the end of PAGE_CONTAINER_AMP:

upload_2017-4-8_12-28-10.webp


And now it works perfect.
 
Top Bottom