Skip to content

Instantly share code, notes, and snippets.

@calvinfo
Last active December 14, 2015 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvinfo/5087538 to your computer and use it in GitHub Desktop.
Save calvinfo/5087538 to your computer and use it in GitHub Desktop.
Once per session tracking
(function () {
var traits = analytics.user.traits()
, session = traits.session
, now = +(new Date); // shim for Date.now in older browsers
if (!session || (now - session) > 60*60*1000) {
// Track things which happen once a session
analytics.track('Once a session');
// Update the user
analytics.user.update({ session : now });
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment