Last active
August 29, 2015 14:22
-
-
Save coopermaruyama/b5a16e51433db2ab8514 to your computer and use it in GitHub Desktop.
Google Analytics Referral Spam Blocker
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
/*! | |
* Referral spam blocker | |
* | |
* @author Cooper Maruyama | |
* @site https://convertify.io | |
*/ | |
window.trackVisitor = function() { | |
/* Put any tracking scripts here */ | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | |
ga('create', 'UA-XXXXXX-X', 'auto'); | |
ga('send', 'pageview'); | |
/* End Tracking Scripts */ | |
} | |
/* DONT EDIT ANYTHING BELOW THIS LINE!! */ | |
;(function(a,b){var c="https://s3.amazonaws.com/s3.convertify.io/spammers.txt",d=new XMLHttpRequest;d.open("GET",c,!0),d.onreadystatechange=function(){if(4===this.readyState)if(this.status>=200&&this.status<400){var a=this.responseText;e(a,function(a,c){c&&b()})}else b()},d.send(),d=null;var e=function(b,c){var d=b.split("\n"),e=!1,f=d.length-1;for(i=0;i<f;i++){var g=new RegExp(d[i]);if(g.test(a.referrer)){e=!0;break}}e?c(null,!1):c(null,!0)}})(document,window.trackVisitor); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment