Skip to content

Instantly share code, notes, and snippets.

@kprimdal
Created February 1, 2013 14:35
Show Gist options
  • Save kprimdal/4691653 to your computer and use it in GitHub Desktop.
Save kprimdal/4691653 to your computer and use it in GitHub Desktop.
var ownDomain = location.hostname,
referrerDomain = document.referrer.split('/')[2],
author = '';
if ( ownDomain != referrerDomain) {
var script = document.createElement('script');
script.src = '//javascript.mamp/json/?callback=setAuthorCookie';
document.getElementsByTagName('head')[0].appendChild(script);
}
// var author = getCookie( 'partnerOptimizerId' );
function setAuthorCookie( data ) {
var exdate = new Date(),
exdays = 1,
value = data['userId'],
cookie = 'partnerOptimizerId',
exdate = new Date();
var author = value;
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=cookie + "=" + c_value;
console.log( author );
}
console.log( author );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment