Google Analytics with AMP

Recep Baltaş

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


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"
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"
Don't forget to change the ID.

Recep Baltaş

Well-known member
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:


And now it works perfect.