// parseUri 1.2.2> // Steven Levithan <stevenlevithan.com></stevenlevithan.com>> // MIT License> > function parseUri (str) {> var o = parseUri.options,> m = o.parserso.strictMode ? “strict” : “loose”].exec(str),> uri = {},> i = 14;> > while (i–) uriio.keyi]] = m[i] || “”;> > urio.q.name] = {};> uri/o.key 12]].replace(o.q.parser, function ($0, $1, $2) {> if ($1) uri o.q.name]a$1] = 2;> });> > return uri;> };> > parseUri.options = {> strictMode: false,> key: :"source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],> q: {> name: "queryKey",> parser: /(?:^|&)(s^&=]\*)=?(;^&]\*)/g> },> parser: {> strict: /^(?:(g^:\/?#]+):)?(?:\/\/((?:((+^:@]\*)(?::((^:@]\*))?)?@)?(:^:\/?#]\*)(?::(\d\*))?))?((((?::^?#\/]\*\/)\*)(?^?#]\*))(?:\?(*^#]\*))?(?:#(.\*))?)/,> loose: /^(?:(?!&^:@]+:s^:@\/]\*@)(^^:\/?#.]+):)?(?:\/\/)?((?:((:^:@]\*)(?::((^:@]\*))?)?@)?(:^:\/?#]\*)(?::(\d\*))?)(((\/(?::^?#](?!?^?#\/]\*\.^^?#\/.]+(?:/?#]|)))*/?)?(]^?#/]*))(?:?(?^#]*))?(?:#(.*))?)/> }> };> > //Get cookie routine by Shelley Powers > function get_cookie(Name) {> var search = Name + “=”> var returnvalue = “”;> if (document.cookie.length > 0) {> offset = document.cookie.indexOf(search)> // if cookie exists> if (offset != -1) { > offset += search.length> // set index of beginning of value> end = document.cookie.indexOf(";", offset);> // set index of end of cookie value> if (end == -1) end = document.cookie.length;> returnvalue=unescape(document.cookie.substring(offset, end))> }> }> return returnvalue;> }> > function setCookie(cname, cvalue, exdays) {> var d = new Date();> d.setTime(d.getTime() + (exdays*24*60*60*1000));> var expires = “expires=”+d.toUTCString();> document.cookie = cname + “=” + cvalue + "; " + expires + “;” + “path=/”;> }> > //Set URL parameters into cookies to store for 1 year to track original parameters - Stuart Mitchell> var cooked_urlpara = get_cookie(“c_urlpara”);> > if (cooked_urlpara != “” && cooked_urlpara != null) { > setCookie (“c_set”, “not set”, 365);> > } else {> > setCookie (“c_urlpara”, parseUri(document.URL).query, 365);> setCookie (“c_utm_medium”, parseUri(document.URL).queryKey.utm_medium, 365);> setCookie (“c_utm_source”, parseUri(document.URL).queryKey.utm_source, 365);> setCookie (“c_utm_content”, parseUri(document.URL).queryKey.utm_content, 365);> setCookie (“c_utm_campaign”, parseUri(document.URL).queryKey.utm_campaign, 365);> setCookie (“c_utm_term”, parseUri(document.URL).queryKey.utm_term, 365);> }Stick that in a JS file, and reference it from your template/header file and it puts the original parameters into cookies for 365 days. I then pull those cookies back into my forms when they are submitted and include them so I can track where the conversion came from originally. I will be expanding this to give some history tracking for multiple visits so I can see the conversion journey.