Skip to content

Instantly share code, notes, and snippets.

@pnghai
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save pnghai/b046ec3fce9682b49a2a to your computer and use it in GitHub Desktop.

Select an option

Save pnghai/b046ec3fce9682b49a2a to your computer and use it in GitHub Desktop.
window.getParameterByName = function(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);
if (results == null) return "";
else return decodeURIComponent(results[1].replace(/\+/g, " "));
}
var capitalizeValue = function (value) {
market_source={
'google_ads': 'Google Ads',
'facebook_ads': 'Facebook Ads',
'gdn': 'GDN',
'banner':'Banner',
'hotline':'Hotline',
'live_chats': 'Live Chats',
'remarketing':'Remarketing',
'retargeting':'Retargeting',
'youtube_ads':'Youtube Ads',
}
if (market_source[value])
{
return market_source[value];
}
else {return 'Khác';}
};
(function(jQuery){
//$("input.subscription_mk_source").val(window.getParameterByName("utm_source"));
jQuery( document ).ready(function( $ ) {
$("input[name='subscription[mk_source]']").val(capitalizeValue(window.getParameterByName("utm_source")));
});
})(window._W && _W.jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment