Writing a Cookie for Third Party Vendor Tracking in Adobe Analytics

I was asked today to help write a value to a cookie in Adobe Analytics without using DTM or another tag manager for tracking a 3rd party vendor’s campaign that was running for a 3 month pilot. This blog posting will show you how to structure your JavaScript within your appMeasurement library to handle this.

To set this up you will need to be able to edit your AppMeasurement.js file. Below is an example of how to set this up:

//write third party cookie, expires in 3 months
if(s.Util.cookieRead('foobar')) {
var thirdPartyData = s.Util.cookieRead('foobar');
tpData = thirdPartyData.split('|');
s.contextData['yoursite.cookie0'] = tpData[0];
s.contextData['yoursite.thirdPartyData'] = thirdPartyData;
var thirdPartyDate = new Date();
thirdPartyDate .setMonth(thirdPartyDate.getMonth() + 3);
s.Util.cookieWrite('foobar', thirdPartyData, thirdPartyDate);
}
function thirdPartyCookie(thirdPartyValue) {
var thirdPartyDate = new Date();
thirdPartyDate.setMonth(thirdPartyDate.getMonth() + 3);
s.Util.cookieWrite('foobar', thirdPartyValue, thirdPartyDate);
}

With this in place you will be able to successfully write a cookie value to Adobe Analytics and leverage it for your third party tracking.

Please Note:

Your set up might be different.  This is just an example to help you in setting this up for your particular needs.

Posted in Adobe Analytics, Web Analytics