Macros can be used in the construction of Real Time Config URLs, see documentation.
@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 -
@adityap2016 The macro names for each of these will be:
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:
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.
Hi @bradfrizzell can we also support canonical url in the macro list? This would allow us to send the correct publisher URL in the bid request.
Sure, I'll add that.
This issue seems to be in Pending Triage for awhile. @bradfrizzell Please triage this to an appropriate milestone.
This issue seems to be in Pending Triage for awhile. @bradfrizzell Please triage this to an appropriate milestone.
As there hasn't been a new request in 10 months, I am closing this.
@bradfrizzell
according to 0.1 source code ATTR(data-json) is not supported now by default and there is a new one REFERRER - may be documentation should be updated accordingly.
Also, data-json (or any other freely configurable param) should be available, for example, if you install several amp-ads with same slot id, you need smth to distinguish one slot from another within rtc request.
@keithwrightbos
I no longer work on this project, Keith can direct you to the appropriate person
@keithwrightbos can you please provide any input?