Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix Google Analytics tracking
/*
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
You can’t perform that action at this time.