Skip to content

Instantly share code, notes, and snippets.

View TimJohns's full-sized avatar

Tim Johns TimJohns

View GitHub Profile
@ryanbattles
ryanbattles / referrer-tracking.js
Created November 16, 2015 16:51
Tracking Referrers
/* --------------------------------------------------
:: Track Referrers
-------------------------------------------------- */
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}