DFP Integration

Setting up a DFP ad placement using the Javscript Ad Tag is similar to the standard integration.

Inline DFP Example

In the Creative Settings section of DFP, enter the code shown below to create an inline ad (i.e. banner or rectangle) placement. In this example, note that the optional passBack parameter will be called once the ad call has completed. This function should take one boolean parameter. This parameter will be true if an ad was successfully returned and false if no ad was returned. Note that <YOUR_APID> should be replaced with your assigned APID.

<script src="http://cdn.millennialmedia.com/mmadlib/v1/mmadlib.js"></script>

<div id="adContainer"></div>

<script type="text/javascript">

    function passBack(adFilled) {
          //adFilled will be true if the ad fills, else it will be false
          console.log("was the ad filled: " + adFilled);
    };

    window.mmAPI.placeAd({
        containerElementId: "adContainer",
        apid: "<YOUR_APID>",
        placementType: "inline",
        width: 320,
        height: 50
    }, passBack);

</script>

The same example shown in the Creative Settings section of DFP. DFPInlineExample

If no passBack funtion is needed, the window.mmAPI.placeAd call will look as follows.

window.mmAPI.placeAd({
    containerElementId: "adContainer",
    apid: "<YOUR_APID>",
    placementType: "inline",
    width: 320,
    height: 50
});

Interstitial DFP Example

Interstitial placements can also be configured in the DFP Creative Settings section. Only the placeAd call itself will differ for the interstitial implementation. Again, note that the passBack parameter is optional and that should be replaced by your assigned APID.

<script src="http://cdn.millennialmedia.com/mmadlib/v1/mmadlib.js"></script>

<div id="adContainer"></div>

<script type="text/javascript">

    function passBack(adFilled) {
          //adFilled will be true if the ad fills, else it will be false
          console.log("was the ad filled: " + adFilled);
    };

    window.mmAPI.placeAd({
        containerElementId: "adContainer",
        apid: "<YOUR_APID>",
        placementType: "interstitial"
    }, passBack);

</script>

The same example shown in the Creative Settings section of DFP. DFPInterstitialExample

If no passBack funtion is needed, the window.mmAPI.placeAd call will look as follows.

window.mmAPI.placeAd({
    containerElementId: "adContainer",
    apid: "<YOUR_APID>",
    placementType: "interstitial"
});

Generating Tags

DFP Tags must be generated and integrated into your site. This option is found in DFP under Inventory > Generate tags. When generating these tags for Javascript Ad Tag ad placements, it is important to check, “Enable sync request.” This will prevent multiple ad requests. DFPTagGeneration