How to use GTM and AMP

,

Google Tag Manager can be used with AMP. The full blog post on its release from Google can be found here. If offers support for a number of tags including Google Analytics, AdWords, etc. You will not be able to add any custom Javascript.

Setup:

  1. AMP has it’s own container type. After choosing to create a new container select AMP.

  2. After clicking create you will be shown the modal below. Only the second script is required as we already include the amp-analytics component for you. Do not add the first script to your page.

  3. Copy the script above and paste it into the Javascript console on your AMP page.

  4. Once installed, you can set up one of the supported tags. Details of the supported tags can be found here.

Note: GTM debugging is not supported for AMP.

3 Likes

Hi @Brian_Burns, I followed these directions to add GTM for GA.

https://amp.blueapron.com/hello-world/amp.html

All went well except I don’t see the amp-analytics tag in my source. The only difference is I set placement to “After Body Tag” to align with GTM instructions (“Paste this at the beginning of the <body> tag”).

Hey @cliodice,

I have to apologize here.

I was just in the process of providing an update wrt to Script Manager as we released a change yesterday which removes Script Manager support for AMP Pages.

We were encountering a number of issues with Script Manager injecting invalid JS into AMPs that were using existing custom domains. As a “quick fix” we’ve removed Script Manager support for AMP until we have a better solution. This will however allow you to use your existing domains as opposed to the previous requirement of adding a new one (as I see you have already done).

For Beta, you’ll need to use the custom JS component in the builder.

Again I am sorry for any inconvenience. We’ll update our documentation to reflect this.

I’ve also just updated the instructions in this post to reflect the change.

1 Like

Thanks for the updates @Cole_Derochie and @Brian_Burns!