Created
December 10, 2013 18:33
-
-
Save adesignl/7895626 to your computer and use it in GitHub Desktop.
Grab Parameters From Tracking URL And Append Them To A Link On Your Site For Further Use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetURLParameter(sParam){ | |
var sPageURL = window.location.search.substring(1); | |
var sURLVariables = sPageURL.split('&'); | |
for (var i = 0; i < sURLVariables.length; i++){ | |
var sParameterName = sURLVariables[i].split('='); | |
if (sParameterName[0] == sParam){ | |
return sParameterName[1]; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var campaign = GetURLParameter('utm_campaign'), | |
medium = GetURLParameter('utm_medium'), | |
source = GetURLParameter('utm_source'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("a.mentorsignup").each(function() { | |
var _href = $(this).attr("href"); | |
if (campaign === undefined) { | |
null; | |
} else { | |
$(this).attr("href", _href + '?utm_campaign=' + campaign + '&utm_medium=' + medium + '&utm_source=' + source); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment