/
Integration with AudienceScience - Multiple Ajax V4

Integration with AudienceScience - Multiple Ajax V4

This document explains how to integrate AudienceScience in a website with e-planning multiple Ajax4 codes.

It is important to do the integration in a beta HTML, which will be ready to be implemented in the real site once approved by AudienceScience.


1) Keyword Creation

Create a 'text with options' type keyword with the following configuration:

Name: gwd

Parameter ID: gwd

Type: Text with options

Options: There must be a value for each space you wish to integrate.

To create a value follow these steps: PQ_PlacementID_LineItem (AudienceScience will provide the PlacementID and LineItem values for each case)

For example, if you wish to integrate 3 spaces (300x250, 728x90 and 160x600), then there must be 3 options in the keyword gwd accordingly:
PQ_6R7eVt_ABCD-li1234
PQ_DZ3pq_ABCD-li1235
PQ_rQ4tq_ABCD-li1236

 

2) Campaign Creation

Create a campaign with your desired configuration.

Important: The campaign must be segmented with the keyword 'gwd' and all its values set as 'positive segmentation':

3) Tags – Ads Load

Copy this tag and replace the orange-colored text for one of the placements. For example: the 728x90 placement is 6R7eVt

<script>
var win = window.top;
document.write('<scri'+'pt type='text/javascript' src='http://' + win.asiAdserver +'/rtbads/pq?mode=s&placement=' + 'PLACEMENT1' + '&adgroup=' + win.asiPlacements['PLACEMENT1'].default.key + '&blob=' + win.asiPlacements['PLACEMENT1'].blob + '&cachebuster=$RANDOM&click=$ENC_LINKURL'></scri'+'pt>');
</script>

Example:

<script>
var win = window.top;
document.write('<scri'+'pt type='text/javascript' src='http://' + win.asiAdserver +'/rtbads/pq?mode=s&placement=' + '6R7eVt' + '&adgroup=' + win.asiPlacements['6R7eVt'].default.key + '&blob=' + win.asiPlacements['6R7eVt'].blob + '&cachebuster=$RANDOM&click=$ENC_LINKURL'></scri'+'pt>');
</script>


It is important to set the ad size and mark the option 'Fixed-size with dynamic loading'


4) Codes

 4A) Zone Codes

The current zone code of the page must be kept. However, the following changes must be performed:

-Positions array: delete all calls to spaces integrated with AudienceScience from the array.
-Function addition: add two functions in green.


<html>
<body>
<script language='JavaScript' type='text/javascript'><!--
var eplDoc = document; var eplLL = false;
var eS1 = 'us.img.e-planning.net';var eplArgs = { iIF:1,sV:schemeLocal() + '://ads.e-planning.net/' ,vV:'4',sI:'1205d',sec:'Home',eIs:['Space_1','Space_2] };
function eplCheckStart() {
    if (document.epl) {
        var e = document.epl;
        if (e.eplReady()) {
            return true;
        } else {
            e.eplInit(eplArgs);
            if (eplArgs.custom) {
                for (var s in eplArgs.custom) {
                    document.epl.setCustomAdShow(s, eplArgs.custom[s]);
                }
            }
            return e.eplReady();       
        }
    } else {
        if (eplLL) return false;
        if (!document.body) return false; var eS2; var dc = document.cookie;
        var cookieName = ('https' === schemeLocal() ? 'EPLSERVER_S' : 'EPLSERVER') + '=';
        var ci = dc.indexOf(cookieName);
        if (ci != -1) {
            ci += cookieName.length; var ce = dc.indexOf(';', ci);
            if (ce == -1) ce = dc.length;
            eS2 = dc.substring(ci, ce);
        }
        var eIF = document.createElement('IFRAME');
        eIF.src = 'about:blank'; eIF.id = 'epl4iframe'; eIF.name = 'epl4iframe';
        eIF.width=0; eIF.height=0; eIF.style.width='0px'; eIF.style.height='0px';
        eIF.style.display='none'; document.body.appendChild(eIF);
       
        var eIFD = eIF.contentDocument ? eIF.contentDocument : eIF.document;
        eIFD.open();eIFD.write('<html><head><title>e-planning</title></head><bo'+'dy></bo'+'dy></html>');eIFD.close();
        var s = eIFD.createElement('SCRIPT');
        s.src = schemeLocal() + '://' + (eS2?eS2:eS1) +'/layers/epl-41.js';
        eIFD.body.appendChild(s);
        if (!eS2) {
            var ss = eIFD.createElement('SCRIPT');
            ss.src = schemeLocal() + '://ads.e-planning.net/egc/4/89bf';
            eIFD.body.appendChild(ss);
        }
        eplLL = true;
        return false;
    }
}
eplCheckStart();
function eplSetAdM(eID,custF) {
    if (eplCheckStart()) {
        if (custF) { document.epl.setCustomAdShow(eID,eplArgs.custom[eID]); }
        document.epl.showSpace(eID);
    } else {
        var efu = 'eplSetAdM(''+eID+'', '+ (custF?'true':'false') +');';
        setTimeout(efu, 250);   
    }
}

function eplAD4M(eID,custF) {
    document.write('<div id='eplAdDiv'+eID+''></div>');
    if (custF) {
        if (!eplArgs.custom) { eplArgs.custom = {}; }
        eplArgs.custom[eID] = custF;
    }
    eplSetAdM(eID, custF?true:false);
}

//Agregar esta función
function eplSetAd(eID) {
    if (eplCheckStart()) {
        var opts = (eplArgs.sOpts && eplArgs.sOpts[eID]) ? eplArgs.sOpts[eID] : {};
        if (opts.custF) { document.epl.setCustomAdShow(eID,opts.custF); }
        document.epl.setSpace(eID, opts);
    } else {
        setTimeout('eplSetAd(''+eID+'');', 250);   
    }
}
//Agregar esta función
function eplAD4(eID, opts) {
    document.write('<div id='eplAdDiv'+eID+''></div>');
    if (!opts) opts = {t:1};
    if (!eplArgs.sOpts) { eplArgs.sOpts = {}; }
    eplArgs.sOpts[eID] = opts;
    eplSetAd(eID);
}

function schemeLocal() {
    if (document.location.protocol) {
        protocol = document.location.protocol;
    } else {
        protocol = window.top.location.protocol;
    }
    if (protocol) {
        if (protocol.indexOf('https') !== -1) {
            return 'https';
        } else {
            return 'http';
        }
    }
}
//--></script> 


4B) Spaces Calls

//Include the named spaces in the array, and delete all calls to the spaces integrated with AudienceScience

 <script type='text/javascript'>eplAD4M('esp_seccion1');</script>
<br>
<script type='text/javascript'>eplAD4M('esp_seccion2');</script>



4C) Prequal Code

Add the following code and replace the corresponding placements, account name, and date.

 <script type='text/javascript' language='JavaScript'>
   var cb = new Date().getTime();
   var asiPqTag = false;
   try {
    document.write('<sc' + 'ript type='text/javascript' language='JavaScript' src='http://pq-direct.revsci.net/pql?placementIdList=DPxZet,YppQzB,6D9eVr&cb=' + cb + ''></sc' + 'ript>');
   } catch(err) { }
</script>

<script>
var asiVars=[''];
if (typeof asiPlacements !== 'undefined') {
    for (var p in asiPlacements) {
        asiVars[p]='';
        asiVars.push(p);
        console.log('p: ' + p);
        for (var key in asiPlacements[p].data) {
            asiVars[p] += 'PQ_' + p + '_' + key;
            console.log('asiVars[' + p + '] = ' + asiVars[p]);
        }
    }
}
else console.log('undefined!');
console.log('here!  ' + cb);

</script>


   

4D) Call to spaces integrated with AudienceScience

Copy the code as in the example, but replace the corresponding placements.

The green line can be obtained from the e-planning interface. (* See instructions below)

Ad request 1:
<script type='text/javascript' language='JavaScript'>
/*var asiPlacements = asiPlacements || top.asiPlacements;
var asiAdserver = asiAdserver || top.asiAdserver;
document.write('<scri'+'pt type='text/javascript' src='http://' + asiAdserver + '/rtbads/pq?mode=s&placement=DPxZet&adgroup=' + asiPlacements['DPxZet']['default'].key + '&blob=' + asiPlacements['DPxZet'].blob + ''></scri'+'pt>');*/

</script>
<script>eplAD4('Space_1',{t:1,timeout:0,ma:1,custF:null,wh:'300x250',sd:'1205d!Home!http://ads.e-planning.net/!!', kVs: { gwd: asiVars['DPxZet'] } });</script>


Ad request 2:
<script type='text/javascript' language='JavaScript'>
/*
var asiPlacements = asiPlacements || top.asiPlacements;
var asiAdserver = asiAdserver || top.asiAdserver;
document.write('<scri'+'pt type='text/javascript' src='http://' + asiAdserver + '/rtbads/pq?mode=s&placement=YppQzB&adgroup=' + asiPlacements['YppQzB']['default'].key + '&blob=' + asiPlacements['YppQzB'].blob + ''></scri'+'pt>');
*/
</script>
<script>eplAD4('Space_2',{t:1,timeout:0,ma:1,custF:null,wh:'160x600',sd:'1205d!FSN!http://ads.e-planning.net/!!', kVs: { gwd: asiVars['YppQzB'] } });</script>

Ad request 3:
<script type='text/javascript' language='JavaScript'>
/*
var asiPlacements = asiPlacements || top.asiPlacements;
var asiAdserver = asiAdserver || top.asiAdserver;
document.write('<scri'+'pt type='text/javascript' src='http://' + asiAdserver + '/rtbads/pq?mode=s&placement=6D9eVr&adgroup=' + asiPlacements['6D9eVr']['default'].key + '&blob=' + asiPlacements['6D9eVr'].blob + ''></scri'+'pt>');*/
</script>
<script>eplAD4('Space_3',{t:1,timeout:0,ma:1,custF:null,wh:'728x90',sd:'1205d!FSN!http://ads.e-planning.net/!!', kVs: { gwd: asiVars['6D9eVr'] } });</script>


   
*Last line of Ad request:

It is the last line of the Ajax space  in e-planning plus the addition in color:

<script>eplAD4('Space_3',{t:1,timeout:0,ma:1,custF:null,wh:'728x90',sd:'1205d!FSN!http://ads.e-planning.net/!!', kVs: { gwd: asiVars['6D9eVr'] } });</script>



See an example of a full implementation attached to this article.
 
Once the call is made, if AS replies with an ad -takes in that impression-, the result will look like this:



 

In this case, the space Space_3 showed the AS ad. Note that it corresponds to the 6D9eVr ¨Placement¨

Related content