I have set a cookie whenever a user clicks through one of our affiliate links and lands on our site with "src=uni" in the URL. The URLs looks something like this: http://ift.tt/1d0QozU]
My Script to set cookie:
function SetCookie() {
var url = window.location.search;
if(url.indexOf('?src=uni') !== -1)
document.cookie="src=uni";
}
When a user makes a purchase, I want the site to look for this cookie on my Receipt page and if it's present, then the tag should have 'FIREuni' : 'TRUE'. If the cookie is not present, the tag should have 'FIREuni' : 'FALSE'.
my object for which I want to set the value of FIREuni based upon cookie presence:
<script type="text/javascript">
function getCookie(src) {
var QryParam = src + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(QryParam) == 0) return c.substring(QryParam.length,c.length);
}
return "";
}
function checkCookie() {
var src=getCookie("src");
if (src!="") {
FIREuni:'TRUE'
var TrackObject = {
'CJ' : {
'CID': '12346',
'TYPE': '7865',
'OID': 'ORDERNUMBER',
'CURRENCY':'USD',
'DISCOUNT': '',
'COUPON': '',
PRODUCTLIST : [
{ 'ITEM': 'item.variant.sku',
'AMT': 'OTOTAL',
'QTY': 'OTY'
},
{ 'ITEM': 'item.variant.sku',
'AMT': 'OTOTAL',
'QTY': 'OTY'
}
]
}};
}
else
{
FIREuni:'FALSE'
var TrackObject ={
'UNI' : {
'CID': '',
'TYPE': '',
'OID': '',
'CURRENCY': '',
'DISCOUNT': '',
'COUPON': '',
PRODUCTLIST : [
{ 'ITEM': '',
'AMT': '',
'QTY': ''
}
]
}
};
}
}
</script>
My Question is how do I change the value based upon the presence of src='uni', can somebody guide me towards a potential solution?
Aucun commentaire:
Enregistrer un commentaire