Campaign URL Builder

This tool allows you to easily create a passback with custom parameters so you can track these in Google Ad Manager.

Enter the following information

Fill out the required fields (marked with *) in the form below, and once complete the full passback script will be generated for you. Note: the generated script is automatically updated as you make changes.

Your Network Code: (e.g. 21834569717)
Your AdUnit ID: (e.g. adtech.dev/test-adunit/)
Passback partner shortcode: (e.g. goog)
Your companies shortcode: (e.g. adtech)
Your passback Name: (e.g. goog_passback_multiplatform__multisize)
Platform type: (e.g. multiplatform)
Enable refresh: (e.g. true)

Your Google Ad Manager Passback

These passbacks can be used in any situation where an ad request to a third party should ultimately be filled by an ad trafficked in your own Ad Manager network.


<!-- Google Ad Manager AdSlot Dynamic Size Passback (by AdTech.dev) ### Size: [[winW,winH]]-->
<script id = 'script-gpt-ad-injected-passback-slot'async src = 'https://securepubads.g.doubleclick.net/tag/js/gpt.js' ></script> 
<script>
  var advertisingConfig = {
    pageURL: window.location.host,
    googleads: {
      networkCode: ,
      adunitId: '',
      slotsTargeting: {
        origin: '',
        originsrc: '',
        originSite: 'unknown_undefined',
        passbackName: '',
        passbackType: '',
        passbackRefresh: '',
      }
    },
    features: {
      refresh: {
        enabled: ,
        gadsViewabilityTime: 30 // Seconds to wait after impression viewable
      },
      headerBidding: {
        enabled: false     
      }
    },
    script: {
      winW: window.innerWidth || window.document.documentElement.clientWidth || 0,
      winH: window.innerHeight || window.document.documentElement.clientHeight || 0,
      adslotW: '',
      adslotH: '',
      supportedAdW: [300, 320, 728, 970],
      supportedAdH: [],
    }
  };
  
  (function init() {
    advertisingConfig.script.adslotW = closestSize(advertisingConfig.script.winW, advertisingConfig.script.supportedAdW);
    if (advertisingConfig.script.adslotW == 0) {
      advertisingConfig.script.supportedAdH = [0]
    } else if (advertisingConfig.script.adslotW == 300) {
      advertisingConfig.script.supportedAdH = [50, 100, 155, 250, 480, 600];
    } else if (advertisingConfig.script.adslotW == 320) {
      advertisingConfig.script.supportedAdH = [50, 100, 480];
    } else if (advertisingConfig.script.adslotW == 728) {
      advertisingConfig.script.supportedAdH = [90]
    } else if (advertisingConfig.script.adslotW == 970) {
      advertisingConfig.script.supportedAdH = [250]
    }
    advertisingConfig.script.adslotH = closestSize(advertisingConfig.script.winH, advertisingConfig.script.supportedAdH);
    if (advertisingConfig.script.adslotW == 0 || advertisingConfig.script.adslotH == 0) {
      return;
    }
    createDiv(advertisingConfig);
    hostDomain(advertisingConfig);
    requestAd(advertisingConfig);
  })();
  
  function closestSize(size, arr) {
    var value = match = 0;
    for (var i = 0; i < arr.length; i++) {
      value = arr[i];
      if (value <= size) {
        match = value;
      }
    }
    return match;
  }
  
  function createDiv(advertisingConfig) {
    var d = document.createElement('div');
    d.setAttribute('class', 'gpt gpt-ad-injected-passback-slot');
    d.setAttribute('id', 'div-gpt-ad-injected-passback-slot');
    d.style.width = advertisingConfig.script.adslotW + 'px';
    d.style.height = advertisingConfig.script.adslotH + 'px';
    var s = window.document.getElementById('script-gpt-ad-injected-passback-slot');
    s.parentNode.insertBefore(d, s);
  }
  
  function hostDomain (advertisingConfig){
    if (window.location.host == 'tpc.googlesyndication.com' || window.location.host == 'partner.googleadservices.com'){
      advertisingConfig.googleads.slotsTargeting.originSite = 'unknown_safeframe';
    } else {
      try {
        var a = window.document.createElement('a');
        a.href = location;
        var hostName = a.hostname;
        var patharray = a.hostname.split('.').reverse();
        if (patharray !== null && patharray.length > 1) {
          advertisingConfig.googleads.slotsTargeting.originSite = patharray[1] + '.' + patharray[0];
          if (hostName.toLowerCase().indexOf('.co.uk') !== -1 && patharray.length > 2) {
            advertisingConfig.googleads.slotsTargeting.originSite = patharray[2] + '.' + advertisingConfig.googleads.slotsTargeting.originSite;
          }
        } 
      } catch(e){}
      }
      return advertisingConfig.googleads.slotsTargeting.originSite;
  }
  
  function requestAd(advertisingConfig) {
    window.googletag = window.googletag || {cmd: []};
    // Set-up adslot and add eventlistener if slot targeting includes refresh=true
    googletag.cmd.push(function () {
      googletag.defineSlot('/' + advertisingConfig.googleads.networkCode + '/' + advertisingConfig.googleads.adunitId, [advertisingConfig.script.adslotW, advertisingConfig.script.adslotH], 'div-gpt-ad-injected-passback-slot')
      .setTargeting('origin', [advertisingConfig.googleads.slotsTargeting.origin])
      .setTargeting('originsrc', [advertisingConfig.googleads.slotsTargeting.originsrc])
      .setTargeting('originsite', [advertisingConfig.googleads.slotsTargeting.originSite])
      .setTargeting('originsz', [advertisingConfig.script.winW + 'x' + advertisingConfig.script.winH])
      .setTargeting('passback', [advertisingConfig.googleads.slotsTargeting.passbackName])
      .setTargeting('passbacktype', [advertisingConfig.googleads.slotsTargeting.passbackType])
      .setTargeting('passbackrefresh', advertisingConfig.googleads.slotsTargeting.passbackRefresh)
      .addService(googletag.pubads());
      googletag.enableServices();
      googletag.display('div-gpt-ad-injected-passback-slot');
      
      if (advertisingConfig.features.refresh.enabled == true) {
      googletag.pubads().addEventListener('impressionViewable', function(event) {
        var slot = event.slot;
        if (slot.getTargeting('passbackrefresh').indexOf(advertisingConfig.googleads.slotsTargeting.passbackRefresh) > -1) {
          setInterval(function() {
            googletag.pubads().refresh([slot]);
          }, advertisingConfig.features.refresh.gadsViewabilityTime * 1000);
        }
      });
    }
  });
  } 
</script>
                

More information and examples for each parameter

The following table gives a detailed explanation and example of each of the parameters that is applied as a key-pair value in the passback ad call.

Network Code

networkCode

Required.

Use networkCode to pass your Google Ad Manager Network Code.

Example: 21834569717

Adunit ID

adunitId

Use adunitId to define the adunit to passback too.

Example: adtech.dev/test-adunit/

Origin ID

origin

Useorigin to pass your parner shortcode into the passback.

Example: goog

Origin Source

originsrc

Use originsrc to pass your companies shortcode.

Example: adtech

Passback Name

passbackName

Use passbackName to pass a unique name into the passback.

Example: goog_passback_multiplatform__multisize

Passback Type

passbackType

Use passbackType to pass a platform value into the passback.

Example: multiplatform

Passback Refresh

passbackRefresh

Use passbackRefresh to enable the passback to refresh after 30 seconds in-view.

Example: true