Load Googletag Ad Unit with Function/jQuery After Page Has Loaded

I have a hidden content element where I have a medium rectangle ad spot. I only want the ad spot to load the googletag ad unit when the element is visible.

I have jquery making the element visible, and I want the same jquery function to create the ad.

Right now in the header I have:

googletag.cmd.push(function() {
    googletag.defineSlot('/133810016/account/300x250', [300, 250], 'div-gpt-ad-33565689741-0').addService(googletag.pubads());
    googletag.pubads().enableSingleRequest();
    googletag.pubads().collapseEmptyDivs();
    googletag.enableServices();

  });

Now, if I have that in the header and the body code in the Medium Rectangle location, the ad runs right away on page load. How do I create the ad unit but don’t call for the ad until a jquery function says to?

All feedback appreciated.

Cheers!
Ryan

Nevermind, I just pulled the included function out of the body div they provide.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.