Add macros to third-party ad tags

Add macros to third-party ad tags

Bidsopt DSP is compatible with a wide range of third-party ad servers. A number of click tracking and cache-busting macros can be used to allow these third parties to track clicks for creatives served through Bidsopt DSP

When you add a third-party ad tag to Bidsopt DSP, you’ll have to insert the macros yourself. Each third party tag looks a little different, but you can use the samples below as a guide.

What is a macro?

A macro is a placeholder (for example:$bo_click) that an ad server replaces with real value when the creative serves. Use macros in your tags when you want Bidsopt DSP to insert information into the tag in real-time.

For example, let’s say you’re using this third-party ad tag:
<script type="text/javascript" src="http://fanpixel.com?click="></script>

The third-party ad server expects a Bidsopt DSP click tracking URL after “click=“. To get this URL, insert a click tracking macro in the tag:
<script type="text/javascript" src="http://example.com?click=$bo_click"></script>

Each time the ad is served, the placeholder $bo_click is replaced with the actual click tracking URL from Bidsopt DSP.

Click tracking and cache-busting macros

Click tracking macros are the most commonly used type of macro. These macros allow third-party ad servers to track a click and associate it with the correct creative, line item, and auction in Bidsopt DSP. Clicking on a creative will first direct users to the Bidospt DSP ad server (to record the click and associated auction information) before redirecting them to the advertiser’s URL.

We also support additional macros depends on the advertiser purpose. The complete list of macros can be found here

Tag and macro examples

Celtra Tag

Before adding click macros:

<div class="celtra-ad-v3">
    <img src="data:image/png,celtra" style="display: none" onerror="
        (function(img) {
            var params = {'clickUrl':'','expandDirection':'undefined','preferredClickThroughWindow':'new','textColor':'#FFFFFF','barColor':'#000000','advertisementMessage':'Advertisement','scrollMessage':'Scroll to continue with content','useFullWidth':'1','offsetTop':'auto','offsetBottom':'auto','clickEvent':'advertiser','externalAdServer':'Custom','tagVersion':'html-standard-7'};
            var req = document.createElement('script');
            req.id = params.scriptId = 'celtra-script-' + (window.celtraScriptIndex = (window.celtraScriptIndex||0)+1);
            params.clientTimestamp = new Date/1000;
            params.clientTimeZoneOffsetInMinutes = new Date().getTimezoneOffset();
            params.hostPageLoadId=window.celtraHostPageLoadId=window.celtraHostPageLoadId||(Math.random()+'').slice(2);
            var qs = '';
            for (var k in params) {
                qs += '&amp;' + encodeURIComponent(k) + '=' + encodeURIComponent(params[k]);
            }
            var src = 'https://ads.celtra.com/95dbbd7f/web.js?' + qs;
            req.src = src;
            img.parentNode.insertBefore(req, img.nextSibling);
        })(this);
    "/>
</div>

After adding click macros:

<div class="celtra-ad-v3">
    <img src="data:image/png,celtra" style="display: none" onerror="
        (function(img) {
            var params = {'clickUrl':'$bo_click','expandDirection':'undefined','preferredClickThroughWindow':'new','textColor':'#FFFFFF','barColor':'#000000','advertisementMessage':'Advertisement','scrollMessage':'Scroll to continue with content','useFullWidth':'1','offsetTop':'auto','offsetBottom':'auto','clickEvent':'advertiser','externalAdServer':'Custom','tagVersion':'html-standard-7'};
            var req = document.createElement('script');
            req.id = params.scriptId = 'celtra-script-' + (window.celtraScriptIndex = (window.celtraScriptIndex||0)+1);
            params.clientTimestamp = new Date/1000;
            params.clientTimeZoneOffsetInMinutes = new Date().getTimezoneOffset();
            params.hostPageLoadId=window.celtraHostPageLoadId=window.celtraHostPageLoadId||(Math.random()+'').slice(2);
            var qs = '';
            for (var k in params) {
                qs += '&amp;' + encodeURIComponent(k) + '=' + encodeURIComponent(params[k]);
            }
            var src = 'https://ads.celtra.com/95dbbd7f/web.js?' + qs;
            req.src = src;
            img.parentNode.insertBefore(req, img.nextSibling);
        })(this);
    "/>
</div>

DV 360 Campaign Manager JavaScript tags

Before adding click macros:

<SCRIPT language='JavaScript1.1' SRC="https://ad.doubleclick.net/ddm/adj/Nxxxx.site-keyname/Byyyyyyy;sz=widthxheight;dc_expa=URL;ord=[timestamp];dc_lat=N;dc_rdid=Czzzz;tag_for_child_directed_treatment=I;kw=[keyword];click=?"> 

After adding click macros:

<SCRIPT language='JavaScript1.1' SRC="https://ad.doubleclick.net/ddm/adj/Nxxxx.site-keyname/Byyyyyyy;sz=widthxheight;dc_expa=URL;ord=$bo_cb;dc_lat=N;dc_rdid=Czzzz;tag_for_child_directed_treatment=I;kw=[keyword];click=$rp_click?">

DV 360 Campaign Manager i-frame/JavaScript tags

Before adding click macros:

<IFRAME SRC="https://ad.doubleclick.net/ddm/adi/Nxxxx.site-keyname/Byyyyyyy;sz=widthxheight;ord=[timestamp];dc_lat=N;dc_rdid=Czzzz;tag_for_child_directed_treatment=I;kw=[keyword];click=?" WIDTH=X HEIGHT=Y MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR='#000000'> 
<SCRIPT language='JavaScript1.1' SRC="https://ad.doubleclick.net/ddm/adj/Nxxxx.site-keyname/Byyyyyyy;abr=!ie;sz=widthxheight;ord=[timestamp];dc_lat=N;dc_rdid=Czzzz;tag_for_child_directed_treatment=I;kw=[keyword];click=?"> 
</SCRIPT> 
</IFRAME> 

After adding click macros:

<IFRAME SRC="https://ad.doubleclick.net/ddm/adi/Nxxxx.site-keyname/Byyyyyyy;sz=widthxheight;ord=$bo_cb;dc_lat=N;dc_rdid=Czzzz;tag_for_child_directed_treatment=I;kw=[keyword];click=$bo_click" WIDTH=X HEIGHT=Y MARGINWIDTH=0 MARGINHEIGHT=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR='#000000'> 
<SCRIPT language='JavaScript1.1' SRC="https://ad.doubleclick.net/ddm/adj/Nxxxx.site-keyname/Byyyyyyy;abr=!ie;sz=widthxheight;ord=$bo_cb;dc_lat=N;dc_rdid=Czzzz;tag_for_child_directed_treatment=I;kw=[keyword];click=$rp_click?"> 
</SCRIPT> 
</IFRAME> 

MOAT wrapped tag with click tracking

In order to record clicks in Bidsopt platform you will need to apply our encoded click macro to the Moat wrapped tags using the following instructions

  1. Find below block in the DCM (or any other platform tag) Moat wrapped blocking tag:
"data-dcm-https-only "+
"data-dcm-resettable-device-id=\x27\x27 "+
"data-dcm-app-id=\x27\x27\x3E "+

2. Insert our click macros in the following line, replacing “HERE” with our escaped/encoded click macro:

"data-dcm-click-tracker=\x27HERE\x27"+

3. Insert that line with our click macro ($rp_click_enc), between the resettable-device-id & app-id lines below

"data-dcm-https-only "+
"data-dcm-resettable-device-id=\x27\x27 "+
"data-dcm-click-tracker=\x27$rp_click_enc\x27"+
"data-dcm-app-id=\x27\x27\x3E "+

Example -before adding click macro

<script type="text/javascript">
(function() {
    var moatApi = {};
    moatApi.rand = Math.floor(Math.random() * 100000000);
    moatApi.loadTimes = {};
    moatApi.loadTimes.t0 = (new Date).getTime();
    moatApi.pcode = "initiativemenadcmdisplaybs877574132224";
    moatApi.level1 = "24229412";
    moatApi.level2 = "Memob.com";
    moatApi.level3 = "274313356";
    moatApi.level4 = "-";
    moatApi.width = "320";
    moatApi.height = "50";
    moatApi.jsonpTO = 600;
    moatApi.fallbackAdTag = "\x3Cscript src=\x22https://z.moatads.com/fallback/ad.js\x22\x3E\x3C/script\x3E";
moatApi.adTag = "\x3Cins class=\x27dcmads\x27 style=\x27display:inline-block;width:320px;height:50px\x27 "+
"data-dcm-placement=\x27N1045428.1920037MEMOB.COM/B24229412.274313356\x27 "+
"data-dcm-rendering-mode=\x27script\x27 "+
"data-dcm-https-only "+
"data-dcm-resettable-device-id=\x27\x27 "+
"data-dcm-app-id=\x27\x27\x3E "+
"\x3Cscript 

Example -after adding click macro

<script type="text/javascript">
(function() {
var moatApi = {};
moatApi.rand = Math.floor(Math.random() * 100000000);
moatApi.loadTimes = {};
moatApi.loadTimes.t0 = (new Date).getTime();
moatApi.pcode = "initiativemenadcmdisplaybs877574132224";
moatApi.level1 = "24229412";
moatApi.level2 = "Memob.com";
moatApi.level3 = "274313356";
moatApi.level4 = "-";
moatApi.width = "320";
moatApi.height = "50";
moatApi.jsonpTO = 600;
moatApi.fallbackAdTag = "\x3Cscript src=\x22https://z.moatads.com/fallback/ad.js\x22\x3E\x3C/script\x3E";
moatApi.adTag = "\x3Cins class=\x27dcmads\x27 style=\x27display:inline-block;width:320px;height:50px\x27 "+
"data-dcm-placement=\x27N1045428.1920037MEMOB.COM/B24229412.274313356\x27 "+
"data-dcm-rendering-mode=\x27script\x27 "+
"data-dcm-https-only "+
"data-dcm-resettable-device-id=\x27\x27 "+
"data-dcm-click-tracker=\x27$rp_click_encc\x27"+
"data-dcm-app-id=\x27\x27\x3E "+
"\x3Cscript

Note: Please make sure any macro used in the tag is compatible with Bidsopt DSP macro list and formats. Bidsopt macro can be found here.

We support only macros with “$”. For example “$bo_click”. Do not use any macro which contains “${” in the macro placeholder. The ad won’t render if you use the incorrect formats.