Skip to main content
All CollectionsObservePoint Custom Tag
OP Custom Tag - Collecting Cookie Values
OP Custom Tag - Collecting Cookie Values
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over 5 months ago

Overview

The code below collects all 1st party cookies set on all pages for all vendors. Due to permissions and limitations with JavaScript, it cannot collect 3rd party cookies.

They are listed in the Variable Summary report under the ObservePoint Tag. The account name is Cookies. The items displayed in the Variables column are the cookie names. Click the Set column to see the values for each cookie.

To capture the following details in an Audit or Journey, paste the snippet below into an Execute Action:

// cookie values;
function runOP() {
function opReqGetAsync(t, e, n) {
var o = "https://opreq.observepoint.com/?acct=" + e,
s = new XMLHttpRequest;
o.concat();
s.onreadystatechange = function() {
4 == s.readyState && 200 == s.status && n(s.responseText)
}, s.open("POST", o, !0), s.send(JSON.stringify(t))
}
var getCookies = function() {
for (var e = document.cookie.split(";"), o = {}, r = 0; r < e.length; r++) {
var c = e[r].trim().split("=");
o[c[0].replace(/ /g, "_").replace(/['"{}]+/g, "").replace(/,/g, "|")] = decodeURIComponent(c[1]).replace(/ /g, "_").replace(/['"{}]+/g, "").replace(/,/g, "|")
}
return o
},
myCookies = getCookies();
opReqGetAsync(myCookies, "cookies");
}
setTimeout(runOP, 800);
Did this answer your question?