I'm setting up A/B tests for a site that is running several adspaces through Google Ad Manager (aka Double Click for Publishers). Part of the test involves moving and resizing the adspaces' iframes, thus we need to serve up different images within the ads. We're trying to avoid having to do this through the Ad Manager dashboard, but the fact that Google's ads are served in an iframe make it so that our front-end Javascript on our test site can't change the img src to the new ad creative.
Is there any way to have the Google Ad iframe accept Javascript changes as the page is loading?
First, it would depends on your safeframe setup (see here for more details about the safeframe API). If your goal is to trigger a function inside your "banner" ad iframe from your parent site :
case 1 : GPT safeframe API not enabled
case 2 : GPT safeframe API enabled you would need to create a dedicated communication protocol through a window postmessage => see here for details
Also, keep in mind the following :
Then, few questions are arising :
That is why I would recommend to handle the "responsive" rendering directly from your Google Publisher Tag setup :
This solution has the advantage to cover all of creative types from your site adserver integration :
Credit for the "wait resize end event".