Created
January 30, 2019 15:39
-
-
Save arturmamedov/14154eb142720c547c4a58e5d44e4cad to your computer and use it in GitHub Desktop.
Google Analytics (analytics.js) get referral `ga_referrer`
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
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