How to load Doubleclick ads along side dynamic content
Asked Answered
C

1

8

I have been trying to get Doubleclick ad tags to load with my dynamic content. I have a website which loads more content as you scroll down rather than having to go to the next page, back a page, etc. However I have been unsuccessful in getting my ads which I have on every 2nd to 3rd page to load.

Does anyone know how to do this?

Thanks.

edit

Code in the header:

<script type='text/javascript'>
    googletag.cmd.push(function() {
    googletag.defineSlot('/XXX/XXX', [300, 250], 'div-gpt-ad-XXX-0').addService(googletag.pubads());

    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
    });
</script>

I have also tried removing "enableSingleRequest" however that didn't seem to help.

Ad code in body:

<div id='div-gpt-ad-XXX-0' style='width:300px; height:250px;'>
    <script type='text/javascript'>
        googletag.cmd.push(function() { googletag.display('div-gpt-ad-XXX-0'); });
    </script>
</div>
Chemesh answered 25/1, 2013 at 10:55 Comment(7)
However I have been unsuccessful in getting my ads which I have on every 2nd to 3rd page to load. - Can we see what you have tried already?Allseed
I haven't really tried anything of use, just simply calling the javascript by function. I was hoping someone else may have the solution, I couldn't find anything on google about it. I also tried calling "googletag.enableServices();" when the new content is appended however that didn't work.Chemesh
Do the ads work if you put them on the initial page load?Allseed
They do work without any issues when being initially loaded.Chemesh
Then your issue lies with how you're trying to display them during the ajax loading. Can we see the code for this?Allseed
Make sure you are not using enable single request... I think that may stop it from working... the refresh method is probably what you need... would need to see code.Synovia
I have updated my question with the current code I am using.Chemesh
C
2

I worked this out.

jQuery.load was stripping the script tags from my html after loading it and DFP didn't like that. I ended up using https://github.com/coop182/jquery.dfp.js and it solved all the issue.

Chemesh answered 29/1, 2013 at 3:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.