I2I: amp-ad-exit URL variable substitution from third-party analytics
Objective
Enable third-party analytics iframes to be the source of URL variable values in <amp-ad-exit> URLs.
Background
https://github.com/ampproject/amphtml/issues/9433 provides a mechanism for collecting analytics signals with vendor-specific JavaScript. <amp-analytics> creates a sandboxed iframe to run the JavaScript. The JS may send an object with its findings back to the host page. Ads may want to include those findings in their exit or click tracking URLs.
Details
A navigation target in the amp-ad-exit config will define a new URL variable referencing the analytics vendor's unique name and the property of their response object to include in the URL. On click, amp-ad-exit will replace the variable with the latest value reported from the iframe.
Example
Suppose that analytics vendor "VendorXYZ" is installed as a 3P analytics iframe by an <amp-analytics> component on the page, and that VendorXYZ's response object has a string property named "findings". Then the creative's amp-ad-exit config would reference it like this:
{
"targets": {
"landingPage": {
"finalUrl": "https://example.com/?verification=_customAnalytics",
"trackingUrls": [
"https://clicktracker.example.com/?verification=_customAnalytics",
],
"vars": {
"_customAnalytics": {
"defaultValue": "no_response",
"vendorAnalyticsSource": "VendorXYZ",
"vendorAnalyticsResponseKey": "findings"
}
}
}
}
}
When the user clicks on the creative, amp-ad-exit would try to find the latest report by VendorXYZ. If there is a report then the string value of the "findings" property would be inserted into the URLs. Otherwise, defaultValue ("no_response" in this case) would be used. The clickable element could also override the variable value as usual.
Roughly breaking this into: creative->ResponseMap and ResponseMap->amp-ad-exit. PR for the latter is at https://github.com/ampproject/amphtml/pull/10714 Awaiting design doc approval on the former.