Google Analytics conversion tracking for AMP

NOTE: This feature is only available for Convert customers.

AMP pages are generated differently compared to standard pages, which means the code used on them has to be adapted specifically for AMP. In this article, you can find the code you need to add to your AMP in order to track conversions inside your Google Analytics account.

NOTE: If you want to implement Google Analytics conversion tracking on an AMP page, do not use our native Google Analytics integration at the same time. It is enough to use the code in this article. 
NOTE: On July 1, 2023, standard Universal Analytics properties will stop processing new hits. Google Analytics 4 does not support Google AMP pages at this time.

Any of the codes below will need to be placed in HTML > Body. AMP validation will return errors if the codes are placed anywhere else.

Tracking Form Submissions

You will need to replace some parts of the code by adding your Google Analytics ID on the 8th and 10th lines and then customizing the"event_name", "event_category", "event_action", and the "event_label" values to match your desired category and action of the event.

Tracking Button Clicks

This code works with only 1 specific button; if more than 1 button needs to be tracked, the code needs to be edited to contain multiple “buttonClick” key - value pairs while each key needs to be unique. Example: “buttonClick1”, “buttonClick2” etc.

You need to replace some parts of the code by adding your Google Analytics ID on the 8th and 10th lines, adding the element ID of the button you want to track on the "selector" line, and then customizing the"event_name", "event_category", "event_action", and the "event_label" values to match your desired category and action of the event.

To get the element ID of a button, right click the button, select Edit CSS. The element ID will appear in the top right corner, as shown in the GIF below:

editcssnew.gif

Tracking Form Submissions and Button Clicks at The Same Time

To track both form submissions and button clicks simultaneously, need to replace some parts of the code by adding your Google Analytics ID on the 8th and 10th lines, adding the element ID of the button you want to track on the "selector" line, and then customizing the "event_name", "event_category", "event_action", and the "event_label" values to match your desired category and action of the event.