• Resolved Fropky

    (@fropki)


    Hi,

    Google DFP slots can be used once per page. As we have different size of topic some has 15 some has only 5 post per topic. We wants to create a limited set of ad slots coz we really do not know how many the topic will require.

    How DFP ads has a unique id. It can only load once. How can be use DFP with AJAX?

    Regards,

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hello @fropki,
    For DFP you can use ALM Variables to increment a counter and create unique IDs for the slots.

    For example:

    <?php $slotname = 'div-gpt-ad-0'. $alm_item .''; // Generate unique ID for the ad slot ?>
    <div id='<?php echo $slotname; ?>'></div>
    <script>
        googletag.cmd.push(function() {
        var slot = googletag.defineSlot('/123456789/GSLOT_EU_728x90', [[728, 90], [300, 60]], '<?php echo $slotname; ?>').
            setTargeting('pos', ['1']).
            addService(googletag.pubads());
            // Display has to be called before
            // refresh and after the slot div is in the page.
            googletag.display('<?php echo $slotname; ?>');
            googletag.pubads().refresh([slot]);
        });
    </script>

    Basically, you pass the $slotname variable into the ads.
    This has worked for other users. Let me know.

    • This reply was modified 5 years, 10 months ago by Darren Cooney.
    Thread Starter Fropky

    (@fropki)

    Thanks dcooney,

    Will update you once I try this on website.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Reusing DFP slots with Next Page addon’ is closed to new replies.