Created
January 18, 2017 13:15
-
-
Save zaimramlan/bead4ac5e24940494c79374dbb474d49 to your computer and use it in GitHub Desktop.
Script to auto append URL Parameters into links within InstaPage
This file contains 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
/* | |
* PROBLEM: Instapage 'says' it appends the URL Parameters into the links in the landing pages, | |
* but they actually did not. | |
* SOLUTION: This is the script made to auto append url parameters into links | |
* | |
* BEGIN ---> | |
*/ | |
$('body').ready(function() { | |
var appended_url; | |
$('.contents').find('a').each(function() { | |
// find the url parameters from the URL | |
url_params = location.search; | |
// replace the '?' from url parameters to '&' | |
// if, the original URL does not already have '?' | |
if($(this).attr('href').indexOf('?') > -1) { url_params = url_params.replace('?', '&'); } | |
// join the current link's URL with the URL parameters | |
appended_url = $(this).attr('href') + url_params; | |
// set the current link's URL to the appended one | |
$(this).attr('href', appended_url); | |
}); | |
}); | |
/* | |
* <--- END | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment