adobeanalytics_nativeConfig tag is easier to implement, as it will use the same tagging methodology you use on your normal web pages. To accomplish this, add the following to your
"pageName": "Adobe Analytics Using amp-analytics tag",
"v1": "eVar1 test value"
This approach sends data to a utility web page via special query string parameters added to the iframeMessage request parameter. In this case, notice that we have added the ampdocUrl AMP variable, and the documentReferrer to the query string parameters pageURL, and refer respectively to the iframeMessage request above. These extra query string parameters can be named whatever you like, as long as your stats.html page (shown below) is configured to collect the appropriate data from them.
adobeanalytics_nativeConfig template also adds query string parameters based on the variables listed in the extraUrlParams section of the amp-analytics tag. In this case, you can see we have specified the pageName and v1 parameters, which will be used by our stats.html page.
Be aware that you can only use a single amp-analytics template at a time and can not use the “adobeanalytics” template as well as the
adobeanalytics_nativeConfig template on the same AMP. If you attempt to do so, you might see an error in the browser console, and you will erroneously inflate your visitor count.
var v_orgId = "1234567@CodingRepoOrg";
var s_account = "reportSuite";
var s_trackingServer = "metrics.codingrepo.com";
var s_visitorNamespace = "publisherNamespace";
var visitor = Visitor.getInstance(v_orgId);
visitor.trackingServer = s_trackingServer;
var s = s_gi(s_account);
s.account = s_account;
s.trackingServer = s_trackingServer;
s.visitorNamespace = s_visitorNamespace;
s.visitor = visitor;
s.pagename = s.Util.getQueryParam("pageName");
As shown above, you can use or link to your existing
AppMeasurement.js (as in our example), or whatever your existing implementation uses, then add the correct configuration parameters. To capture the correct values into the correct variables, you can use the provided
s.Util.getQueryParam function to grab the value(s) that you passed in from the iframeMessage URL and set the appropriate variables, just as you would on a typical page. If you use tag management software like Adobe’s Dynamic Tag Manager, the query string parameters should be straightforward to capture. In this case,
s.pageName is set to the value we passed in the query string parameter pageName. Here, the page name would be set to Adobe Analytics Example 2.
To reiterate, if your organization is not yet using the Marketing Cloud ID service (or has tag management software like Adobe’s Dynamic Tag Manager), you can tag the stats.html page however you want. Use your existing implementation as a reference point. The only difference from your standard implementation is that you will get the applicable data points from the
amp-analytics iframeMessage URL (or document.URL from within the stats.html page ) for each of the variables you want to set. Also, if you want to use any of the AMP specific variables (as mentioned above) like the AMP referrer or AMP page URL, please include them in the iframeMessage object as shown in our example above.
As flexible as this solution is, there are caveats. Due to inherent restrictions in the
amp-analytics iframeMessage, it can only be loaded on a page load once. This means you will not be able to do link tracking or video tracking with the
adobeanalytics_nativeConfig template. Moreover, some DOM values that are typically captured automatically by our AppMeasurement code, such as referrer (which impacts the Search Engine Keyword reports, Referrer, and Referrer Type reports, or may include a marketing campaign tracking code) will have to be passed manually to the iframeMessage using whatever AMP variables are available. For this reason, Adobe recommends setting a custom variable with the value AMP if you put AMP data into an existing report suite, so that you can segment out AMP traffic when viewing the aforementioned reports. That said, standard technology reports, such as browser, device, screen size or resolution, should work automatically.