Technical question regarding GPT in Asynchronous Mode

Published by: Albert Santos , GreatSchools, us
Published on: September 10, 2012

We're using GPT in Asynchronous Mode. We've also called enableSingleRequest() because we need roadblocking. The page is set up with multiple tabs in hidden divs; clicking on a specific tab will make the associated div visible. There's an ad that we want to show on one of the hidden divs but we don't want an impression recorded for it until we show the containing div as a result of user action. How can we do this?

Our best guess was to try calling pubService.disableInitialLoad(), which disables the initial fetch of ads from Google when the page is first loaded. The documentation says that calls to refresh() can still be used to fetch ads.

We have some questions regarding this:

1. If disableInitialLoad() is called, at what point are impressions counted? In single-request mode, are they counted once the code in the head gets executed (e.g. defineSlot, enableServices, etc.)? Or do impressions only get counted when display() is called? Or only when refresh() is called? Since a user might never switch to the tab on which the ad we want to show would be displayed, we don't want to have extra impressions counted inadvertently.

2. How can we know when we're able to call refresh() after disableInitialLoad(). We tried calling it immediately after and nothing happened. We tried waiting a few seconds (via setTimeout) and it worked. Ideally, there's some callback we could call once refresh() would work.

3. After calling disableInitialLoad() and then refresh() on all ads, some of the ads had nothing to render, but they didn't collapse even though we had called collapseEmptyDivs(). Is this a bug, or is there some other way to get the ad to collapse when using disableInitialLoad()? Ad slots with no ads to serve collapse properly when not using disableInitialLoad() followed by refresh().

4. Is there a better way to do what we want, without using disableInitialLoad()?