Level 2
January 15, 2017
Solved
Doubleclick Javascript Error
- January 15, 2017
- 7 replies
- 2416 views
This is linked to implementing the code via DTM.
I have since made progress on the code and I will explain it here for the benefit of anybody who needs it. The way the code is designed seems to be in the wrong order where it presents the DFA Variables, the Code itself and then the plugins required. To make it work properly, it needs to be restructured so that it goes DFA Variables, Plugins and THEN the code. This ensures the variables called in the code are available. Here's the code which has worked for me so far when placed in Library Management (below).
/************************** DFA VARIABLES **************************/
/* @TODO: Fill in these variables with the settings mapped in the
* DFA wizard and that match your desired preferences. Some of the
* variables are optional and have been labeled as such below.
* @TODO: Comments should be removed in a production deployment. */
var dfaConfig = {
CSID: '', // DFA Client Site ID
SPOTID: 'XXXXXXXX', // DFA Spotlight ID
tEvar: 'XXXXXX', // Transfer variable, typically the "View Through" eVar.
errorEvar: 'XXXXX', // DFA error tracking (optional)
timeoutEvent: 'XXXXXX', // Tracks timeouts/empty responses (optional)
requestURL: "XXXXXX", // the DFA request URL
maxDelay: "XXXXXX", // The maximum time to wait for DFA servers to respond, in milliseconds.
visitCookie: "XXXXXX", // The name of the visitor cookie to use to restrict DFA calls to once per visit.
clickThroughParam: "XXXXXX", // A query string paramter that will force the DFA call to occur.
searchCenterParam: XXXXXX, // SearchCenter identifier.
newRsidsProp: XXXXXX // Stores the new report suites that need the DFA tracking code. (optional)
};
/************************ END DFA Variables ************************/
/*
* Partner Plugin: DFA Check 1.0 - Restrict DFA calls to once a visit, per report suite, per click
* through. Used in conjunction with VISTA. Deduplicates SCM hits.
*/
s.partnerDFACheck=new Function("cfg",""
+"var s=this,c=cfg.visitCookie,src=cfg.clickThroughParam,scp=cfg.searchCenterParam,p=cfg.newRsidsProp,tv=cfg.tEvar,dl=',',cr,nc,q,g,gs,i,j,k,fnd,v=1,t=new Date,cn=0,ca=new Array,aa=new Array,cs=new A"
+"rray;t.setTime(t.getTime()+1800000);cr=s.c_r(c);if(cr){v=0;}ca=s.split(cr,dl);if(s.un)aa=s.split(s.un,dl);else aa=s.split(s.account,dl);for(i=0;i<aa.length;i++){fnd = 0;for(j=0;j<ca.length;j++){if(aa[i] == ca[j]){fnd=1;}}if(!fnd){cs[cn"
+"]=aa[i];cn++;}}if(cs.length){for(k=0;k<cs.length;k++){nc=(nc?nc+dl:'')+cs[k];}cr=(cr?cr+dl:'')+nc;s.vpr(p,nc);v=1;}if(s.wd)q=s.wd.location.search.toLowerCase();else q=s.w.location.search.toLowerCase();q=s.repl(q,'?','&');g=q.indexOf('&'+src.toLow"
+"erCase()+'=');gs=(scp)?q.indexOf('&'+scp.toLowerCase()+'='):-1;if(g>-1){s.vpr(p,cr);v=1;}else if(gs>-1){v=0;s.vpr(tv,'SearchCenter Visitors');}if(!s.c_w(c,cr,t)){s.c_w(c,cr,0);}if(!s.c_r(c)){v=0;}r"
+"eturn v>=1;");
/********************************************************************
*
* Supporting functions that may be shared between plug-ins
*
*******************************************************************/
/*
* Utility Function: vpr - set the variable vs with value v
*/
s.vpr=new Function("vs","v",
"if(typeof(v)!='undefined' && vs){var s=this; eval('s.'+vs+'=\"'+v+'\"')}");
/*
* Utility Function: split v1.5 - split a string (JS 1.0 compatible)
*/
s.split=new Function("l","d",""
+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x++]=l.substring(0,i);l=l.substring(i+d.length);}return a");
/*
* Plugin Utility: Replace v1.0
*/
s.repl=new Function("x","o","n",""
+"var i=x.indexOf(o),l=n.length;while(x&&i>=0){x=x.substring(0,i)+n+x.substring(i+o.length);i=x.indexOf(o,i+l)}return x");
/************************** DFA CODE START **************************/
s.maxDelay = dfaConfig.maxDelay;
s.loadModule("Integrate");
s.Integrate.onLoad=function(s,m) {
var dfaCheck = s.partnerDFACheck(dfaConfig);
if (dfaCheck) {
s.Integrate.add("DFA");
s.Integrate.DFA.tEvar=dfaConfig.tEvar;
s.Integrate.DFA.errorEvar=dfaConfig.errorEvar;
s.Integrate.DFA.timeoutEvent=dfaConfig.timeoutEvent;
s.Integrate.DFA.CSID=dfaConfig.CSID;
s.Integrate.DFA.SPOTID=dfaConfig.SPOTID;
s.Integrate.DFA.get(dfaConfig.requestURL);
s.Integrate.DFA.setVars=function(s,p) {
if (window[p.VAR]) { // got a response
if(!p.ec) { // no errors
s[p.tEvar]="DFA-"+(p.lis?p.lis:0)+"-"+(p.lip?p.lip:0)+"-"+(p.lastimp?p.lastimp:0)+"-"+(p.lastimptime?p.lastimptime:0)+"-"+(p.lcs?p.lcs:0)+"-"+(p.lcp?p.lcp:0)+"-"+(p.lastclk?p.lastclk:0)+"-"+(p.lastclktime?p.lastclktime:0)
} else if (p.errorEvar) { // got an error response, track
s[p.errorEvar] = p.ec;
}
} else if (p.timeoutEvent) { // empty response or timeout
s.events = ((!s.events || s.events == '') ? '' : (s.events + ',')) + p.timeoutEvent; // timeout event
}
}
}
}
/************************** DFA CODE END **************************/
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.