Closed massawho closed 4 years ago
@massa1240 thank you for the feature request with all these details.
IIUC, you want your creatives served from GAM to read PAGE_VIEW_ID. As you already noticed, the window.context
API doesn't work because it is designed for ad tags but not creatives.
using amp-iframe to relay the message seems like an interesting work around, but it definitely abuses the purpose of amp-iframe. we should have a more straightforward support in amp-ad
.
One thing you can already do is to convert your ad into AMPHTML ads, and you will immediately get access to PAGE_VIEW_ID via <amp-analytics>
in the creative, together with other speed & security benefits of AMPHTML ads.
If that is not an option for you (for example, it does not support fancy interactive ad formats, such as a mini game), we will need to introduce creative facing APIs in amp-ad
.
@ampproject/wg-ads
Hi @lannka ! Thanks for your reply
but it definitely abuses the purpose of amp-iframe. we should have a more straightforward support in amp-ad.
I totally agree with this statement, which made me not feel very comfortable implementing this solution in the beginning... due the circunstances, I decided to give this a shot, as it was the solution that made me closer to achieve what I had to.
Something I have achieved tho was passing a send-intersections
postMessage
and listen it back in my creative. If we had a similiar functionality to fetch amp metadata, would be awesome!
One thing you can already do is to convert your ad into AMPHTML ads, and you will immediately get access to PAGE_VIEW_ID via
in the creative, together with other speed & security benefits of AMPHTML ads.
I actually tried this (I will be giving another shot to make sure I am not crazy here), but this didn't work. Whenever I place an <amp-analytics>
in my creative, it doesn't get fired. I also filled a support question on google forum (https://support.google.com/admanager/thread/24272321?hl=en), got some upvotes but no answers so far. Same happens for amp-pixel
. Using amp-img
could possibly do the trick but I also can't use dynamic variables on it. Just one question here: if I place a PAGE_VIEW_ID
inside my creative, will it be the same as the PAGE_VIEW_ID
in my parent? I thought it wouldn't be since it comes from a new request, so it would generate its own value, and I will have more than one creative in the same page that all must share the same PAGE_VIEW_ID
. Another attempt I gave a shot was firing amp-analytics
to my in-house service using linkers
, but so far I got nowhere. Caleb suggested to push my code to a working environment, since I am using localhost to make tests and this could be possibly bugging the code as I am using different ports (for different docker containers/web services). I will continue on his suggestion and see if I can reach somewhere, but I am not so confident as I have tried using amp-analytics
before in my creative.
@massa1240 I just tested on my side, and could confirm that the child PAGE_VIEW_ID is the same as parent's when both are firing through amp-pixel. What is your setting? Are they cross domain?
Hi, @powerivq just a quick question, are you using iframe
for this test? Because it could be slightly different from what I am testing. My ultimate goal is to send impression events from my Google DFP creative, so yes, they are cross-domain. However, any amp-analytics
or amp-pixel
I place on my creative doesn't get fired at all. I haven't tested firing pixels from an iframe
because it doesn't actually help as I still have to fetch some data from my creative before sending the pixel...
@massa1240 I am using <amp-ad type=fake>
to include an AMPHTML ads that has amp-pixel and amp-analytics on it. The parent page also has amp-analytics and amp-pixel.
I tried both cross domain and same domain, both are able to send out the same PAGE_VIEW_ID
.
@massa1240 do you have a demo that we can play with?
after a long discussion, we decided that this is not the best approach to deal with this issue. I will be writing a new I2C that would solve the same problem in a proper way using amp-ad
Summary
Enable dynamic variable macros (ie: PAGE_VIEW_ID) on
amp-iframe
src
attribute.Motivation
We are moving our in-house ads server to Google Ad Manager and I have to integrate creative information that is generates on-the-fly by Google with an in-house tracker that requires some set of specific requirements to track those ad impressions.
We display 4 creatives per page (3 from a same slot called Sponsor Listing and 1 from a different slot called Display Ad). Each creative has its own
impression_id
using%%CACHEBUSTER%%
macro and I have to dispatch one ad impression event for each of them. However, along with theimpression_id
I have to add thepage_view_id
to my impression event, which is generated by an AMP macro in the parent page. Because of the nature of x-origin iframes, it's not trivial to share these variables.I have considered:
window.context
, but there is an issue from 2017 that is still in triage https://github.com/ampproject/amphtml/issues/12342 . That would be the best solution I could think of, but I can't have access towindow.context
at all from my creative.postMessage
from my creative and listening to themessage
events, but I wasn't able to set awindow.addEventListener
in myamp-script
. Related issue https://github.com/ampproject/worker-dom/issues/747message
events from my creative and have access towindow.context
, but I also didn't have access towindow.context
.amp-analytics
linkers, but I also have no success with that. Google Ad Manager simply doesn't fire any event to myamp-analytics
, which made me to abort this.iframe
and add anamp-script
topostMessage
to this mediatoriframe
. The mediatoriframe
would catch themessage
from the parent page and from the creative and once both information are avaiable, it would dispatch the ad impression event. However, myamp-script
is able to find theamp-iframe
tag, but I can't find the theiframe
usingdocument.querySelector
, which I believe this is expectable sinceiframe
is generated dynamically.amp-iframe
attribute doesn't support dynamic variables. => This is my intention to implementAdditional context
We currently have similar behaviour happening on our current ads server, but because we pass json data instead of using
amp-ad
oramp-iframe
, it's much straightfoward: we use anamp-list
and call our ads server passing the macro as thepage_view_id
. From there, our server fires the events. Since we are moving from our ads server to Google Ad Manager, we need to keep the behaviour, but now we need to rely on client capabilities./cc @ampproject/wg-approvers @clawr @lannka @calebcordry @sebastianbenz