Amp and Adwords

Tutorial: How to get Google Adwords tracking to work with Google AMP.

Don’t get me wrong, AMP is great. It’s just that it is new and the documentation is lacking. A couple sentences and no code is not enough to be able to figure out what to do without looking through the source code. Lucky for you, I dug through the source code and figured out how to actually use Google Adwords with AMP.

Just add this HTML to your AMP page and replace the required values. Please note, not all of the variables are required so you can remove the ones you don’t need.

Conversion tracking

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<amp-analytics type="googleadwords">
<script type="application/json">
{
"vars": {
"googleConversionId": "TODO",
"googleConversionLabel": "TODO",

"googleConversionColor": "TODO",
"googleConversionLanguage": "TODO",
"googleConversionCurrency": "TODO",
"googleConversionValue": "TODO"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "conversion"
}
}
}
</script>
</amp-analytics>

Remarketing tracking

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 <amp-analytics type="googleadwords">
<script type="application/json">
{
"vars": {
"googleConversionId": "TODO",
"googleConversionLabel": "TODO"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "remarketing"
}
}
}
</script>
</amp-analytics>

https://developers.google.com/adwords/amp/landing-pages#conversion_tracking_and_remarketing
https://github.com/ampproject/amphtml/pull/7273/files#diff-43075fef96144a4f898edb8d18aae69a