amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

Add network-level RTC macros for doubleclick rtc implementation

Open bradfrizzell opened this issue 8 years ago • 28 comments

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:

bradfrizzell avatar Dec 08 '17 17:12 bradfrizzell

@nibuca FYI

Aerlinger avatar Dec 08 '17 18:12 Aerlinger

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.

nibuca avatar Dec 12 '17 20:12 nibuca

Other ones I have had requested, adding here for posterity:

data-slot, width, height and multisize parameters

bradfrizzell avatar Dec 19 '17 20:12 bradfrizzell

@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 -

  1. data-slot
  2. width
  3. height
  4. multiSize
  5. overrideWidth
  6. overrideHeight
  7. Json Targeting

adityap2016 avatar Jan 02 '18 15:01 adityap2016

@adityap2016 The macro names for each of these will be:

  1. DATASLOT
  2. WIDTH
  3. HEIGHT
  4. MULTISIZE
  5. OVERRIDEWIDTH
  6. OVERRIDEHEIGHT
  7. JSON

bradfrizzell avatar Jan 02 '18 15:01 bradfrizzell

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:

  1. ATTR(data-slot)
  2. ATTR(width)
  3. ATTR(height)
  4. ATTR(data-multi-size)
  5. ATTR(data-override-width)
  6. ATTR(data-override-height)
  7. 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.

bradfrizzell avatar Jan 03 '18 21:01 bradfrizzell

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

AmazonPublisherServices avatar Jan 04 '18 01:01 AmazonPublisherServices

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 avatar Jan 04 '18 14:01 bradfrizzell

@bradfrizzell Wanted to confirm if window.context.location.href is already available in __amp_source_origin parameter?

monish-chhadwa avatar Jan 04 '18 14:01 monish-chhadwa

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()}` 

AmazonPublisherServices avatar Jan 04 '18 19:01 AmazonPublisherServices

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

bradfrizzell avatar Jan 04 '18 19:01 bradfrizzell

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)?

AmazonPublisherServices avatar Jan 04 '18 20:01 AmazonPublisherServices

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 avatar Jan 09 '18 23:01 nibuca

@nibuca I'm currently investigating and will see if I can make this available. Will update once I get a better sense.

bradfrizzell avatar Jan 16 '18 20:01 bradfrizzell

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.

bradfrizzell avatar Jan 25 '18 20:01 bradfrizzell

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.

nibuca avatar Jan 25 '18 20:01 nibuca

Hi @bradfrizzell, Checking in on this. Please let me know if you'd like to hop on a call to discuss this.

nibuca avatar Jan 30 '18 18:01 nibuca

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.

bradfrizzell avatar Jan 30 '18 18:01 bradfrizzell

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

bradfrizzell avatar Feb 11 '18 23:02 bradfrizzell

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.

bradfrizzell avatar Feb 13 '18 18:02 bradfrizzell