Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Google Analytics (analytics.js) get referral `ga_referrer`
ga(function(tracker) {
var ga_refferer = tracker.get('referrer'); // this get the referral from google analytics.js
if (typeof wCookies != 'undefined' && typeof wCookies().get('ga_refferer') == 'undefined') {
if (typeof ga_refferer != 'undefined') {
wCookies().set('ga_refferer', ga_refferer, {expires: 30});
} else {
wCookies().set('ga_refferer', 'direct', {expires: 30});
}
}
});
// useed with
// https://github.com/arturmamedov/withFront/blob/master/js/core/w-core.js // for clog() function that can be removed
//
// https://github.com/js-cookie/js-cookie
// https://github.com/arturmamedov/withFront/blob/master/js/core/w-cookie.js // for wCookies() function wrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.