Created
September 9, 2021 23:03
-
-
Save tzookb/79f7ba3dacf28d34464a3d43a7486962 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Identify Graph Solution | |
(function () { | |
var cordialAccountKey = 'cordialdev'; | |
var traverse = { | |
advertiserId: "64ea99ec-de50-4c40-ab11-fb064620ab22", | |
campaignId: "61c8349c-1668-4422-9171-99b2bd4e989b", | |
}; | |
/** | |
* will read the cookie value and return that specific cookie name | |
* @param string name | |
* @returns | |
*/ | |
var readCookie = function(name) { | |
var nameEQ = name + "="; | |
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, c.length); | |
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); | |
} | |
return null; | |
} | |
var getBID = function(accountKey) { | |
try { | |
var cookieName = 'v2_'+accountKey; | |
var cookie = readCookie(cookieName); | |
var d = JSON.parse(decodeURI(cookie)) | |
return d.bid; | |
} catch(error) { | |
console.log(error); | |
} | |
} | |
/** | |
* will load traverse data with the needed items | |
*/ | |
var handleTRS = function() { | |
var s = document.createElement('script'); | |
s.type = 'text/javascript'; | |
s.async = true; | |
s.src = 'https://static.traversedlp.com/v1/retargeting.js'; | |
s.onload = function () { | |
var bid = getBID(cordialAccountKey); | |
if (!bid) { | |
return; | |
} | |
TraverseRetargeting.init({ | |
advertiserId: traverse.advertiserId | |
}); | |
TraverseRetargeting.include({ | |
campaignId: traverse.campaignId, | |
advertiserProperties: { | |
accountKey: cordialAccountKey, | |
bid: bid | |
} | |
}); | |
}; | |
var x = document.getElementsByTagName('script')[0]; | |
x.parentNode.insertBefore(s, x); | |
} | |
var initGraphIdentifier = function() { | |
handleTRS() | |
} | |
initGraphIdentifier(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment