Shoora
10/18/2018 - 2:09 PM

Fix Google Analytics tracking

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');