adobeanalytics tracking template utilizes the
amp-analytics tag to construct a tracking request directly. Using the
adobeanalytics template in the
amp-analytics tag, you can specify hit requests that fire on specific page events, like the page becoming visible or on a click (and in the future, video views and more). Click events can be customized to apply to certain element IDs or classes by specifying a selector. Adobe has made this easy to set up using the
adobeanalytics template specifically designed for Adobe Analytics. You can load the template by adding
type="adobeanalytics" to the
In the following code example, there are two triggers defined: pageLoad and click. The pageLoad trigger will fire when the document becomes visible and will include the pageName variable as defined in the vars section. The second trigger click will fire when a button is clicked. eVar 1 will be set for this event with the value button clicked.
"pageName": "Adobe Analytics Using amp-analytics tag"
"eVar1": "button clicked"
In the click trigger, you can specify a selector to ensure that whenever the specific DOM element is clicked (in this case, any button), the buttonClick request is fired and will be automatically set to denote this hit as a non-stage event (i.e. trackLink call).
adobeanalytics supports a number of variable substitutions so that AMP can provide data values that it is aware of. You can learn all about those and more by visiting:
adobeanalytics variable documentation.
Be aware that if you want to incorporate any technology or DOM variables (such as browser, screen size, device, referrer, etc.) you will have to explicitly add them to any request, as they are not automatically generated for you. Documentation on each of our available query string parameters used for tracking can be found here.
If you inspect the hits created by
adobeanalytics, you will notice that in each request, Adobe has included the vid query parameter. We set the vid based on a built-in AMP function to set a custom Analytics cookie ID named adobe_amp_id. This ID is independent of any other ID being set by Adobe Analytics elsewhere (e.g.s_vi cookie) and creates new visitors in any report suite the hits are sent to.
There are a few caveats to be aware of. When using the
adobeanalytics tag as mentioned above, visitors will be independent of your normal tracking, and because the AMP can be loaded from any content delivery network, you will get a unique visitor for each CDN a visitor sees this AMP on (hence the visitor inflation mentioned previously). For this reason, Adobe recommends that if you use the
adobeanalytics template for
adobeanalytics, you put your data into a separate report suite specific to AMP. Also, the Marketing Cloud ID service (formerly, visitor ID service) is not supported using this method, so if your business requires additional Marketing Cloud integrations, or will in the future, this is probably not the option for you.
Finally, and perhaps most importantly, this