Add network-level RTC macros for doubleclick rtc implementation
Macros can be used in the construction of Real Time Config URLs, see documentation.
Currently available macros for DoubleClick (with definition):
- PAGEVIEWID - pageViewId
- HREF - equivalent to window.context.location.href
- ATTR(height) - Height attribute of the amp-ad element
- ATTR(width) - Width attribute of the amp-ad element
- ATTR(data-slot) - data-slot attribute of the amp-ad element
- ATTR(data-multi-size) - data-multi-size attribute of the amp-ad element
- ATTR(data-multi-size-validation) - data-multi-size-validation attribute of the amp-ad element
- ATTR(data-override-width) - data-override-width attribute of the amp-ad element
- ATTR(data-override-height) - data-override-height attribute of the amp-ad element
- ATTR(data-json) - data-json attribute of the amp-ad element
- ADCID - adClientId
- TGT - Just the targeting piece of data-json
- CANONICAL_URL - The canonical URL of the page.
- TIMEOUT - The publisher-specified timeout for the RTC callout.
Currently requested macros backlog for DoubleClick:
@nibuca FYI
Thanks! I don't currently have a pressing need for them, but making the ad call variable available (adunit, json attributes, height, width, etc) seems like it would be something that may come up in the future.
Other ones I have had requested, adding here for posterity:
data-slot, width, height and multisize parameters
@bradfrizzell - Please confirm the macro names that will be supported. We will need these for the pull request.
The ones that we need in the RTC call are -
- data-slot
- width
- height
- multiSize
- overrideWidth
- overrideHeight
- Json Targeting
@adityap2016 The macro names for each of these will be:
- DATASLOT
- WIDTH
- HEIGHT
- MULTISIZE
- OVERRIDEWIDTH
- OVERRIDEHEIGHT
- JSON
Hey @adityap2016
So quick update to my above. I didn't realize that we already had a standard way of doing the macros for element attributes, so the proper way to specify them will actually be:
- ATTR(data-slot)
- ATTR(width)
- ATTR(height)
- ATTR(data-multi-size)
- ATTR(data-override-width)
- ATTR(data-override-height)
- ATTR(data-json)
What is contained within the parentheses is case insensitive, e.g. ATTR(DATA-SLOT), ATTR(Data-Slot), and ATTR(data-slot) all work. So in a url, it may look like:
https://www.example.com/?width=ATTR(width)&height=ATTR(height)
Apologies for the change. This should be merged in for the next AMP release. Please let me know if you have any questions or concerns.
Hey @bradfrizzell,
I have two questions/requests. We would like to use window.context.location.href, will that be encoded previous to constructing the vendor URL? We would also like to use a cachebuster macro, one that uses a combination of a random number and date.now(), is that a possibility?
Thanks, Jason
hey @AmazonPublisherServices window.context.location.href is now available as a macro as HREF, see https://github.com/ampproject/amphtml/pull/12539
I will update the top level comment here with a list of all available macros. I can also definitely add a cache buster macro. I'll have that in for you in the next few days.
@bradfrizzell Wanted to confirm if window.context.location.href is already available in __amp_source_origin parameter?
Great, thanks @bradfrizzell. This string literal is what I had in mind for a cachebuster if it works for you guys,
`${Math.round(Math.random() * 1000000000)}${Date.now()}`
hey @AmazonPublisherServices, out of curiosity, is there a reason why you couldn't just set no-cache headers on the RTC response? i.e. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
Hey @bradfrizzell, we could do that, but it also doubles as our bid request id which we use in other areas of our library (latency analysis, TTL, etc...). If you don't want to make it a cachebuster per se, we can set the headers on the response, but then can I request one for something like ATTR(bidReqID)?
Hey @bradfrizzell Am I correct that PAGEVIEWID is the equivalent of window.context.pageViewId which was available in the amp-3p-iframe-src file ?
If so, is there an equivalent to window.context.clientId ?
@nibuca I'm currently investigating and will see if I can make this available. Will update once I get a better sense.
Hi @nibuca, sorry for slow back and forth. So I can add in clientId if this is something you need. However, there are some issues. The primary problem is that clientId is not available yet at the time when we are currently building the RTC call. Get the clientId is an async process, whereas all the RTC macro operations currently are sync. Adding this change would mean that your RTC requests would potentially be slowed down by using clientId, and this would count against your timeout. If this is a feature you need anyways, let me know and I will get working on it.
Hi @bradfrizzell
We have been using the combination of clientId and pageviewId to generate a distinct userId (we refer to it as vguid) which would be available to both ads and our analytics. This vguid is used so that we can match visits in our analytics with visits in ads.
If we can generate the vguid in RTC and then share it back to analytics (or vice versa) I'm happy with that option.. but we need some way to have a shared value.
Hi @bradfrizzell, Checking in on this. Please let me know if you'd like to hop on a call to discuss this.
Hi @nibuca
We can make the client ID available, but if there is a synchronous way we could generate an equivalent vguid that would be ideal. Would be happy to jump on a call.
Hi @nibuca Please refer to PR to add this functionality for you here: https://github.com/ampproject/amphtml/pull/13434
Will have this merged in before the cut on Tuesday.
Best, Brad
hey @nibuca Just a heads up, apparently there is no canary release this week (presumably due to so much of the team being away for AMP Conf). I'll still aim to have PR #13434 in today, and can show you how to test against local if needed.