DFP and GPT Passbacks

Setting up a Passback for DFP and GPT Tags

If you are using DFP and requesting Smaato via Ad Tag you can pass an ad request back from a NoAd-response to DFP, by following these steps:

Prerequisite

You’ll need to have the following already set up:

  • An adspace in SPX that represents your inventory
  • A line item in SPX to go along with the above (this can be the default Line Item or a specific one)
  • A line item in DFP with the according to Ad Tag – use this snippet with your Publisher and Adspace IDs:
<div id="smaatoad" style="padding:0px"></div>
<script type="text/javascript" src="https://soma-assets.smaato.net/js/smaatoAdTag.js"></script>
<script>
    function callBackForSmaato(status){
        if(status == "SUCCESS"){
            console.log("SUCCESS");
        } else if (status == "ERROR"){
            console.log("ERROR");
        }
    };
    
SomaJS.loadAd({
    adDivId: "smaatoad",
    publisherId: REPLACE_WITH_PUBLISHER_ID,
    adSpaceId: REPLACE_WITH_ADSPACE_ID,
    dimension: "xxlarge",
    ref: "%%PATTERN:url%%"
},callBackForSmaato);
</script>

If you have all of the above set up, you should be able to send ad requests from DFP to Smaato and receive ads in case of a successful ad call.

Set up another ad unit in DFP

The Ad Unit needs to be unique to the Passback and not used for anything else. Mostly, it makes sense to use the original Ad Unit’s name and to add *PB*, (passback) or a similar note to the name.

Set up your GPT tag

This one is a little bit tricky; fortunately, you’ll only have to do most of the legwork once.

Head over to https://support.google.com/dfp_sb/answer/1651549#noEdit, and follow the instructions on setting up a GPT tag. Please note that unfortunately, you’re not able to use the auto-generated passback tag from within the DFP UI.

This tag contains the routing back to your DFP account, and should look something like this:

<script type="text/javascript">
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function() {
        var gads = document.createElement('script');
        gads.async = true;
        gads.type = 'text/javascript';
        var useSSL = 'https:' == document.location.protocol;
        gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
        var node = document.getElementsByTagName('script')[0];
        node.parentNode.insertBefore(gads, node);
    })();
</script>
<div id="div-gpt-ad-1234567891234-0">
    <script type="text/javascript">
        googletag.cmd.push(function() {
            googletag.defineSlot('/1234/sports/football', [320, 50], 'div-gpt-ad-1234567891234-0')
                .addService(googletag.pubads())
                .setTargeting('Gender','Male');
            googletag.enableServices();
            googletag.display('div-gpt-ad-1234567891234-0');
        });
    </script>
</div>

DFP + Autoreload Issue

If the ad uses auto reload, possible bugs might cause issues when DFP detects that the ad with the same uniqueID has been already rendered. To solve this issue, it is necessary to append an extra command inside the tag snippet provided by DFP.

<script type="text/javascript">
    googletag = undefined;
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function() {
        var gads = document.createElement('script');
        gads.async = true;
        gads.type = 'text/javascript';
        var useSSL = 'https:' == document.location.protocol;
        gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
        var node = document.getElementsByTagName('script')[0];
        node.parentNode.insertBefore(gads, node);
    })();
</script>
<div id="div-gpt-ad-1234567891234-0">
    <script type="text/javascript">
        googletag.cmd.push(function() {
            googletag.defineSlot('/1234/sports/football', [320, 50], 'div-gpt-ad-1234567891234-0')
                .addService(googletag.pubads())
                .setTargeting('Gender','Male');
            googletag.enableServices();
            googletag.display('div-gpt-ad-1234567891234-0');
        });
    </script>
</div>

2| googletag = undefined;

Set up a House Line Item in SPX

To send NoAds back to DFP please follow the steps below:

  • First, follow the instructions on https://developers.smaatolabs.net/publishers/spx-direct-orders/ for setting up a House Line Item.
  • Then set up an HTML creative and paste your GPT tag in there.
  • Next, target this house line item to your Adspace (as mentioned above).
  • Now, make sure that the House Line Item is also set to a lower priority than the line item that you’d like to use to get Smaato demand from.

Modified: June 11, 2019 at 5:31 pm