Created
February 24, 2014 10:40
-
-
Save Rendez/9185389 to your computer and use it in GitHub Desktop.
Create a 'returning visitor' or 'new visitor' property for Mixpanel.
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
/** | |
* If the mixpanel cookie exists this user was in the site before, | |
* we have to consider him returning, only every 24 hours, just like GA. | |
*/ | |
var RETURNING_VISITOR = document.cookie.indexOf('_mixpanel') != -1; | |
// if the mixpanel cookie does not exists the user is considered new | |
if (!RETURNING_VISITOR) { | |
$.cookie('mp_visitor', true, { expires: 1, path: '/' }); | |
// else the user might not be returning. | |
} else if ($.cookie('mp_visitor') !== null) { | |
RETURNING_VISITOR = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment