Google Tag Manager

How to Track AMP Pages in Google Analytics with Google Tag Manager

AMP Google

Accelerated Mobile Pages or AMP is an open source initiative aimed at making it easy to present static web content on mobile devices. This means that AMP pages and their content are significantly quicker to load than other pages. News, blogs and other publishing sites are key users of AMP as their focus is on delivering large amounts of content to their users. We won’t be going into detail here about AMP itself please read our introduction to AMP for more information.

In this post we will show you how to track AMP pages in Google Analytics via Google Tag Manager. By the end you will have a new GTM container specifically for your AMP pages. You will have configured Google Analytics to receive your AMP data and you will have successfully setup a page view tracking tag.

The GTM Container

To track AMP pages you will need to setup an entirely new GTM container. This is an AMP specific container and so you cannot use any existing Web GTM containers. The tag types, triggers and variables all differ from those in the more familiar web container.

Step 1: Creating the Container

  1. Login to your GTM account and create a new Container.
  2. Give the Container a descriptive name like: mysite.com – AMP
  3. Select AMP in the Where to Use Container section

Step 2: Implementing the Container

Once you have created the container you will be presented with the GTM installation instructions and code.

You will need to implement the container on all of your AMPs. Once this is completed you will be ready to set up tracking tags.

Configuring Google Analytics

Before you can set up your tags you must have a Google Analytics property to send your data too. You can use your existing property for this though you need to make sure you are able to identify your AMP pages from regular ones. For example if your AMP URLs include /amp/ you can easily distinguish AMP from non-AMP. You can simply search for /amp/ in your page reports or create a custom view with a filter to only include pages with /amp/ in the URL.

If however your AMP URLs are indistinguishable from your regular URLs you can create a custom dimension to mark the AMP pages. You can do this even if you have a way of telling the pages apart and want a consolidated view of AMP and non-AMP pages. To set this up you need to visit the admin tab of your Google Analytics account.

  1. Under the Property settings select Custom Definitions and then Custom Dimensions.
  2. Click the red button to add a New Custom Dimension.
  3. Name you Custom Dimension ‘AMP Status’.
  4. Ensure the scope is set to Hit and the Active checkbox is checked.
  5. Click Create and then Done.

  1. In the Custom Dimensions Table note the Index of your new Custom Dimension as we will need it when we create the Page View Tag.

You can now use this custom dimension in the Google Analytics Page View Tag in GTM.

Creating the Page View Tag and Trigger

To set up the Page View Tag go back to GTM and create a new tag.

  1. Name your tag ‘Google Analytics Page View’
  2. Under Tag Configuration select Universal Analytics.
  3. Input your GA property’s Tracking ID.
  4. Ensure the Track Type is Page View.
  5. If you have setup the custom dimension in Google Analytics then click on More Settings.
  1. Click on Custom Dimensions and then Add Custom Dimensions.
  2. Input the Index of the Custom Dimension you created earlier.
  3. For the Dimension Value input: AMP Page.
  4. It is important to repeat this process for the GA Page View Tag in your GTM Web container but using the Dimension Value: Non-AMP.

Now that the tag is setup you need to create the trigger.

  1. Click on Triggering
  2. Select the All Pages trigger
  3. Finally save the tag.

Congratulations! You have now set up Page View tracking for your AMP pages in Google Analytics. You can now publish the container and your tag will be live on your site.

Your new GTM AMP container gives you new functionalities to expand your AMP page tracking. Learn about these new functionalities in the second part of our tutorial about Event Tracking for AMP pages.

If you have any questions about setting up your AMP tracking, please send me an email.

Don't miss our GTM Articles.

Check out our Analytics services.