Created
August 19, 2016 14:10
-
-
Save xrem/5af9966147b53ba90d6457be56339d7c to your computer and use it in GitHub Desktop.
blog.radario.ru
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
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