Skip to content

Instantly share code, notes, and snippets.

@zaimramlan
Created January 18, 2017 13:15
Show Gist options
  • Save zaimramlan/bead4ac5e24940494c79374dbb474d49 to your computer and use it in GitHub Desktop.
Save zaimramlan/bead4ac5e24940494c79374dbb474d49 to your computer and use it in GitHub Desktop.
Script to auto append URL Parameters into links within InstaPage
/*
* 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