Reputation: 441
I have a data element using a custom script with a default value of "_Not_Set_". The code in the data element is:
var elemNavValue = _satellite.readCookie('navElemName');
console.log("spot 1 - cookie value is " + elemNavValue);
if ((elemNavValue !== '')&&(elemNavValue !== undefined)&&(elemNavValue !== '_Not_Set_')){
console.log("spot 2 - cookie value is " + elemNavValue);
_satellite.setCookie('navElemName','_Not_Set_',1);
return elemNavValue;
}else{
console.log("spot 3 - cookie value is " + elemNavValue);
_satellite.setCookie("navElemName",'_Not_Set_',1);
return '_Not_Set_';
}
When the page loads, I see the data element runs twice. I get the following output in the console.
spot 1 - cookie value is undefined
spot 3 - cookie value is undefined
spot 1 - cookie value is _Not_Set_
spot 3 - cookie value is _Not_Set_
This is the only data element I have declared and it is only called in the global section for Adobe Analytics tool and assigned to a prop and eVar. I have no rules created. Why is this and how do I fix this issue?
Upvotes: 4
Views: 631
Reputation: 800
Instead of being created once on page load, Data elements run each time they are called. So, if you are using them in a prop and evar,it will be called twice. If you run
_satellite.getVar('data element name')
in the browser console, you would see the code run again. To stop this behavior, copy the evAR into the prop or vice versa.
Upvotes: 4