Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
blog.radario.ru
var days = 7; // Количество дней хранения в cookie. (Сейчас 7)
var utmSource = getParameterByName('utm_source');
var set = false;
var attr;
if (utmSource) {
attr = utmSource; // Дополнительный параметр для кнопопк data-utm-source
$.cookie('utm', utmSource, { expires: days });
set = true;
} else if ($.cookie('utm')){
utmSource = $.cookie('utm');
attr = utmSource; // Дополнительный параметр для кнопопк data-utm-source
set = true;
}
if (set) {
jQuery(document).ready(function($) {
$(".utmbutton").find('script').attr('data-utm-source', attr);
});
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment