Mobile app version of vmapp.org
Login or Join
Odierno851

: Google Tag Manager and AMP I am setting up AMP for my news site. Does anyone know if there is Google Tag Manager Support? I know you can use Google Analytics. I wonder if I use GA tracking

@Odierno851

Posted in: #Amp #GoogleAnalytics #GoogleTagManager

I am setting up AMP for my news site. Does anyone know if there is Google Tag Manager Support? I know you can use Google Analytics. I wonder if I use GA tracking code on all /amp/ pages it will track double.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Odierno851

2 Comments

Sorted by latest first Latest Oldest Best

 

@Gretchen104

Google Tag Manager now added AMP support.
All you need is to


create a GTM container of type "AMP"
Include the following code in <head>

<!-- AMP Analytics --><script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>

Include the following code into <body>

<!-- Google Tag Manager -->
<amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-XXXXXX&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics>



Find some more info about that on Simo Ahava's blog www.simoahava.com/analytics/accelerated-mobile-pages-via-google-tag-manager

10% popularity Vote Up Vote Down


 

@Gonzalez347

I originally tried adding the GTM using Glue for Yoast SEO and it did track the pages. However, that resulted in 2 AMP validation errors:



The proper way of implementing the tag as of right now is via amp-pixel or amp-analytics. I used amp-analytics tag myself. First you would add this in the head:

<script async custom-element="amp-analytics"
src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>


And then the tracking code goes in the body inside this tag using JSON:

<amp-analytics type="googleanalytics" id="analytics1"></amp-analytics>


Full details can be found here:

Adding Analytics to your AMP pages

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme