Created
December 7, 2016 05:30
-
-
Save girvan/30afe7578a78d8cc8317a1e390139e7a to your computer and use it in GitHub Desktop.
Fix Google Analytics tracking
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
/* | |
setup: paste before ga('send', 'pageview'); | |
features: | |
- fix *.search.yahoo.com to Organic | |
- fix Line and WeChat Apps to Social | |
*/ | |
(function(r, M, S){ | |
if(r.match(/^https?:\/\/\w+\.search\.yahoo\.com\//)) | |
{ga('set',M,'Organic');ga('set',S,'Yahoo!');return} | |
if(r)return;var m=navigator.userAgent.match(/\W(MicroMessenger|Line)\W/); | |
if(!m)return;ga('set',M,'Social');ga('set',S,m[1].replace(/M.*/,'WeChat')) | |
})(document.referrer,'campaignMedium','campaignSource'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment