Skip to content

Instantly share code, notes, and snippets.

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