amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

I2I: Add CLIENT_ID to amp-ad[rtc-config]

Open massawho opened this issue 6 years ago • 8 comments

Summary

Enable CLIENT_ID macro to be used on amp-ad RTC.

Design document

Motivation

We are moving our in-house ads server to Google Ad Manager and I have to integrate creative information that is generated on-the-fly by Google with an in-house tracker that requires some set of specific requirements to track those ad impressions. Because AMP pages are the source of most of our traffic, we are getting blocked of continuing the project without proceeding with the proposed feature.

The ultimate goal is to: display 4 creatives per page (3 from the same slot called Sponsor Listing and 1 from a different slot called Display Ad). Each creative has its own impression_id which is passed from the parent page and rendered in the creative by a macro and I have to dispatch one ad impression event for each ad. However, along with the impression_id I have to add the page_view_id along with client_id to my impression event, which is generated by an AMP macro on the parent page. Because of the nature of x-origin iframes, it's not trivial to share these variables.

Because I also have to inject some targeting information from my server, the idea is to pass the CLIENT_ID value into the RTC and finally catch it using %%patern%% macro on Google Ad Manager. This is how we currently do on our responsive pages, but when trying to implement CLIENT_ID with RTC, we noticed that this macro is not available (doc: https://github.com/ampproject/amphtml/blob/master/extensions/amp-ad-network-doubleclick-impl/doubleclick-rtc.md#available-url-macros). Instead, we have ADCID available, which doesn't solve the problem. There is also a GitHub issue open for this issue, but there are no answers https://github.com/ampproject/amphtml/issues/25190

Additional context

Other methods we considered using:

  • Using window.context, but it didn't work at all since my iframe comes from a cross-domain.
  • Using amp4ads, but we also had cross-domain issues. While I was able to achieve some macros (PAGE_VIEW_ID), some aren't shared between parent and child pages (CLIENT_ID) and for the current state, this is essential to be available, including the cookies we use to generate the client_id value. Also, in order to use amp4ads on Google Ad Manager, we would have to change a lot our current configuration that is already solid.
  • Send a postMessage from my creative and listening to the message events, but I wasn't able to set a window.addEventListener in my amp-script. Related issue ampproject/worker-dom#747
  • Create a mediator iframe and add an amp-script to postMessage to this mediator iframe. The mediator iframe would catch the message from the parent page and from the creative and once both information is available, it would dispatch the ad impression event. However, my amp-script is able to find the amp-iframe tag, but I can't find the iframe using document.querySelector, which I believe this is expectable since iframe is generated dynamically.
  • To have my mediator iframe to receive dynamic parameters and, in the request, I would dispatch events to my tracker (based on our current implementation, it's actually easier to fire events from server-side). However amp-iframe attribute doesn't support dynamic variables. I've created an I2C for this, but it was rejected for valid reasons. https://github.com/ampproject/amphtml/issues/26274

Launch tracker

/cc @ampproject/wg-approvers

massawho avatar May 06 '20 06:05 massawho

Sorry, not sure I fully understand. Could you explain why ADCID does not work for your use-case?

calebcordry avatar May 11 '20 21:05 calebcordry

Hi @calebcordry unless I misunderstood how adClientId works, it doesn't give us the desired value. Currently, we use CLIENT_ID(AMP_ECID_GOOGLE,,_ga) on both parent page and ads when firing tracking events because we need to know what ads were shown in a given page load. Because we display ads using amp-list with our current ads-server we have this macro available, however, Google uses iframes to display ads, so we are trying to figure out how to have the same behaviour and values with amp-ad + the limitations of having a cross-domain origin iframe. I've made an attempt using the ADCLIENTID macro but I got a totally different value from using CLIENT_ID.

massawho avatar May 12 '20 08:05 massawho

Alright, I did a sanity check and indeed they almost give me the same value, but not quite. You will notice that when I use ADCID GA1.2. gets appended while using CLIENT_ID it only returns amp-hKsywMdr9hRy0ERBK8dCNg.

Using ADCID(AMP_ECID_GOOGLE,,_ga) on my amp-ad
GA1.2.amp-hKsywMdr9hRy0ERBK8dCNg
Using CLIENT_ID(AMP_ECID_GOOGLE,,_ga) on amp-analytics / amp-pixel
amp-hKsywMdr9hRy0ERBK8dCNg
Using CLIENT_ID(AMP_ECID_GOOGLE) on amp-analytics
amp-72WCXboBwgYhCjKd6hZTLA
Value inside AMP_ECIDE_GOOGLE: amp-72WCXboBwgYhCjKd6hZTLA
Value inside _ga: GA1.2.amp-hKsywMdr9hRy0ERBK8dCNg

massawho avatar May 12 '20 11:05 massawho

Thanks for the detailed report. If we allow the CLIENT_ID macro in the json attribute (#25190) would that also solve your use case?

calebcordry avatar May 14 '20 16:05 calebcordry

Hi @calebcordry , I believe on the json attribute would be even better as macros count to the timeout of the RTC and I am not yet sure if we will be able to respond within the current limit of ~1s! Thanks a lot for looking through this tho. I guess the best is to close this I2I and wait for the solution to be implemented?

massawho avatar May 19 '20 14:05 massawho

Hi @massa1240 and @calebcordry, reaching out to you because this would be required to work on the rtc attribute (it currently doesn't). That's the attribute that is used to place a request to an RTC-compatible endpoint that returns this targeting data The json attribute will not resolve the need because the page would need to be loaded, for each visitor, with targeting data set in that attribute. That can be done for pages that are not cached. But if a page is cached, be it in the publisher's own CDN or by Google's itself, then it's not possible to populate that attribute with personalized values for each visitor.

ivansurif avatar Nov 10 '20 13:11 ivansurif

Hi @massa1240 and @calebcordry, adding to the latter comment, please note that I'm reaching out on behalf of Piano DMP, which is used by major publishers globally. This issue has turned into a blocker for us affecting AMP implementations

ivansurif avatar Nov 10 '20 14:11 ivansurif

Hi all, we are now also allowing CLIENT_ID to be used in RTC callouts as of #31949. I believe this addresses all concerns in this thread. Please reopen if I missed something.

calebcordry avatar Feb 02 '21 22:02 calebcordry