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.
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:
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.