Skip to content

Instantly share code, notes, and snippets.

@dillansimmons
dillansimmons / firstTouchUTMCookie.js
Created October 25, 2016 19:29
Store first touch utm in cookie and input into hidden field (Cookie.js, JQuery)
// Initiate JQUERY
// Initiate cookie.js : https://github.com/js-cookie/js-cookie
// Parse the URL
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, " "));
}
// Give the URL parameters variable names