var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
return false;
};
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(91357132, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true
});
jQuery(document).ready(function($){
var source = getUrlParameter('utm_source');
link_yandex = 'https://t.me/+xQU6z_37q_wzNDky';
link_mytarget = 'https://t.me/+i7Aphqqjmi84NzIy';
link_vk = 'https://t.me/+9_iPZ_ggJyU0ODIy';
link_empty = 'https://t.me/+usq4WXQAHIsyOTli';
if(source == 'yandex') {
$('#tg a').attr('href', link_yandex);
} else if(source == 'mytarget') {
$('#tg a').attr('href', link_mytarget);
} else if(source == 'vk') {
$('#tg a').attr('href', link_vk);
} else {
$('#tg a').attr('href', link_empty);
}
$("body").on('click', '#ways', function(){
ym(91357132,'reachGoal','way');
});
$("body").on('click', '#site', function(){
ym(91357132,'reachGoal','site');
});
$("body").on('click', '#tg', function(){
ym(91357132,'reachGoal','tg');
});
});
/*document.addEventListener('click', function (event) {
// If the clicked element doesn't have the right selector, bail
if (!event.target.matches('#ways')) return;
// Don't follow the link
ym(91357132,'reachGoal','way');
// Log the clicked element in the console
console.log('way');
}, false);
document.addEventListener('click', function (event) {
// If the clicked element doesn't have the right selector, bail
if (!event.target.matches('#site')) return;
// Don't follow the link
ym(91357132,'reachGoal','site')
// Log the clicked element in the console
console.log('site');
}, false);
document.addEventListener('click', function (event) {
// If the clicked element doesn't have the right selector, bail
if (!event.target.matches('#tg')) return;
// Don't follow the link
ym(91357132,'reachGoal','tg')
// Log the clicked element in the console
console.log('tg');
}, false);*/