Skip to content

Instantly share code, notes, and snippets.

@christiantakle
Created July 3, 2014 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christiantakle/51c938b0eab11542ce40 to your computer and use it in GitHub Desktop.
Save christiantakle/51c938b0eab11542ce40 to your computer and use it in GitHub Desktop.
Naive implementaion of referrer tracking
//-- Polyfill ---------------------------------------------------------
if ( !String.prototype.contains ) {
String.prototype.contains = function() {
return String.prototype.indexOf.apply( this, arguments ) !== -1;
};
}
//-- Module -----------------------------------------------------------
(function(exports, document, undefined) {
var namespace = 'tools';
, makeReferrerTest =
function(string) {
return function() {
return document
.referrer
.toLowerCase()
.contains(string);
};
}
exports[namespace] = {
makeReferrerTest: makeReferrerTest
};
}(window, document));
var fromBilletto = tools.makeReferrerTest('billetto');
if(fromBilletto()) {
// you count implementation Ajax,Ga what not
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment