1function updateTrackingLinks() { 2 const urlParams = new URLSearchParams(window.location.search); 3 const source = resolveTrackingSource(urlParams); 4 5 // 1. ÐонÑигÑÑаÑÐ¸Ñ 6 const defaultNumberText = "+7 777 598 6571"; // Ð¢Ð¾Ñ ÑамÑй номеÑ, коÑоÑÑй иÑем и менÑем 7 let newNumberText = defaultNumberText; 8 let whatsappText = 9 "ÐдÑавÑÑвÑйÑе, пиÑÑ Ñ ÑайÑа. (ÐÑоÑим ÐÐ ÑдалÑÑÑ Ð³Ð¾Ñовое ÑообÑение)."; 10 11 // ÐпÑеделÑем новÑй номеÑ: UTM, ÑеÑеÑÐµÑ 2ÐÐС или ÑÐ¾Ñ ÑанÑннÑй иÑÑоÑник 12 if (source === "google") { 13 newNumberText = "+7 700 046 84 38"; 14 whatsappText = 15 "ÐдÑавÑÑвÑйÑе, пиÑÑ Ñ ÑÐµÐºÐ»Ð°Ð¼Ñ Google. (ÐÑоÑим ÐÐ ÑдалÑÑÑ Ð³Ð¾Ñовое ÑообÑение)."; 16 } else if (source === "2gis") { 17 // ÐÑделÑного номеÑа 2ÐÐС пока Ð½ÐµÑ â ÑÑавим Ð½Ð¾Ð¼ÐµÑ Google 18 newNumberText = "+7 700 046 84 38"; 19 whatsappText = 20 "ÐдÑавÑÑвÑйÑе, пиÑÑ Ñ 2ÐÐС. (ÐÑоÑим ÐÐ ÑдалÑÑÑ Ð³Ð¾Ñовое ÑообÑение)."; 21 } else if (source === "instagram") { 22 newNumberText = "+7 700 046 84 40"; 23 whatsappText = 24 "ÐдÑавÑÑвÑйÑе, пиÑÑ Ñ ÑÐµÐºÐ»Ð°Ð¼Ñ Instagram. (ÐÑоÑим ÐÐ ÑдалÑÑÑ Ð³Ð¾Ñовое ÑообÑение)."; 25 } else if (source === "tiktok") { 26 newNumberText = "+7 700 046 84 41"; 27 whatsappText = 28 "ÐдÑавÑÑвÑйÑе, пиÑÑ Ñ ÑÐµÐºÐ»Ð°Ð¼Ñ TikTok. (ÐÑоÑим ÐÐ ÑдалÑÑÑ Ð³Ð¾Ñовое ÑообÑение)."; 29 } else if (source === "yandex") { 30 newNumberText = "+7 700 046 84 39"; 31 whatsappText = 32 "ÐдÑавÑÑвÑйÑе, пиÑÑ Ñ ÑÐµÐºÐ»Ð°Ð¼Ñ Ð¯Ð½Ð´ÐµÐºÑ. (ÐÑоÑим ÐÐ ÑдалÑÑÑ Ð³Ð¾Ñовое ÑообÑение)."; 33 } 34 35 // ÐÑли UTM Ð½ÐµÑ Ð¸Ð»Ð¸ иÑÑоÑник не из ÑпиÑка â ниÑего не делаем Ñ ÑекÑÑом 36 if (newNumberText === defaultNumberText && !urlParams.has("utm_source")) { 37 // ÐналиÑÐ¸ÐºÑ Ð²Ñе Ñавно навеÑим ниже, но Ð·Ð°Ð¼ÐµÐ½Ñ ÑекÑÑа пÑопÑÑÑим 38 } 39 40 const cleanDefault = defaultNumberText.replace(/\D/g, "").slice(-10); // беÑем поÑледние 10 ÑиÑÑ Ð´Ð»Ñ ÑоÑного ÑÑÐ°Ð²Ð½ÐµÐ½Ð¸Ñ 41 const cleanNewTel = "tel:+" + newNumberText.replace(/\D/g, ""); 42 const finalWhatsappUrl = 43 "https://wa.me/77775986571?text=" + encodeURIComponent(whatsappText); 44 45 const phoneRegex = 46 /(\+?7|8)[\s\-]?\(?\d{3}\)?[\s\-]?\d{3}[\s\-]?\d{2}[\s\-]?\d{2}/g; 47 48 // 2. ÐбновлÑем ÑелеÑоннÑе ÑÑÑлки 49 $("a[href*='tel:']").each(function () { 50 const currentHref = $(this).attr("href").replace(/\D/g, "").slice(-10); 51 52 // ÐенÑем href и ÑекÑÑ Ð¢ÐÐЬÐРеÑли Ð½Ð¾Ð¼ÐµÑ Ð² ÑÑÑлке ÑÐ¾Ð²Ð¿Ð°Ð´Ð°ÐµÑ Ñ Ð½Ð¾Ð¼ÐµÑом по ÑмолÑÐ°Ð½Ð¸Ñ 53 if (currentHref === cleanDefault) { 54 $(this).attr("href", cleanNewTel); 55 56 // ÐÑем и менÑем ÑекÑÑ ÑолÑко еÑли он ÑÐ¾Ð²Ð¿Ð°Ð´Ð°ÐµÑ Ñ default 57 $(this) 58 .find("*") 59 .contents() 60 .addBack() 61 .contents() 62 .each(function () { 63 if (this.nodeType === 3) { 64 const oldText = this.nodeValue; 65 const match = oldText.match(phoneRegex); 66 67 if (match) { 68 // ÐÑовеÑÑем, ÑÑо найденнÑй в ÑекÑÑе Ð½Ð¾Ð¼ÐµÑ â ÑÑо Ð½Ð°Ñ Ð´ÐµÑолÑнÑй 69 const foundClean = match[0].replace(/\D/g, "").slice(-10); 70 if (foundClean === cleanDefault) { 71 this.nodeValue = oldText.replace(phoneRegex, newNumberText); 72 } 73 } 74 } 75 }); 76 } 77 78 // ÐналиÑÐ¸ÐºÑ Ð²ÐµÑаем на вÑе звонки (или можно Ñоже обеÑнÑÑÑ Ð² if) 79 $(this).attr( 80 "onclick", 81 "gtag('event', 'phoneclick', {send_to: 'G-JYQ2D4YSDV'}); fbq('track', 'Lead'); ttq.track('Contact'); ym(99750807, 'reachGoal', 'phoneclick'); return true;" 82 ); 83 }); 84 85 // 3. ÐбновлÑем WhatsApp (ÑикÑиÑованнÑе номеÑа конÑеÑенÑ-зала не ÑÑогаем) 86 $("a[href*='wa.me'], a[href*='whatsapp.com']").each(function () { 87 if (!$(this).attr("data-wa-phone")) { 88 $(this).attr("href", finalWhatsappUrl); 89 } 90 $(this).attr( 91 "onclick", 92 "gtag('event', 'whatsappclick', {send_to: 'G-JYQ2D4YSDV'}); fbq('track', 'Lead'); ttq.track('Contact'); ym(99750807, 'reachGoal', 'whatsappclick'); return true;" 93 ); 94 }); 95} 96 97const ASYR_SRC_COOKIE = "asyr_src"; 98const ASYR_SRC_DAYS = 30; 99const ASYR_KNOWN_SOURCES = ["google", "instagram", "tiktok", "yandex", "2gis"]; 100 101function getTrackingCookie(name) { 102 const parts = ("; " + document.cookie).split("; " + name + "="); 103 if (parts.length < 2) return ""; 104 return decodeURIComponent(parts.pop().split(";").shift() || ""); 105} 106 107function setTrackingCookie(name, value, days) { 108 const maxAge = days * 24 * 60 * 60; 109 let cookie = 110 name + 111 "=" + 112 encodeURIComponent(value) + 113 "; path=/; max-age=" + 114 maxAge + 115 "; SameSite=Lax"; 116 if (location.protocol === "https:") cookie += "; Secure"; 117 document.cookie = cookie; 118} 119 120function hostFromReferrer(referrer) { 121 try { 122 return new URL(referrer).hostname.replace(/^www\./, "").toLowerCase(); 123 } catch (e) { 124 return ""; 125 } 126} 127 128function is2gisReferrer(referrer) { 129 const host = hostFromReferrer(referrer); 130 return /(^|\.)2gis\.(com|ru|kz)$/.test(host); 131} 132 133function normalizeTrackingSource(raw) { 134 if (!raw) return null; 135 const source = String(raw).toLowerCase().trim(); 136 if (ASYR_KNOWN_SOURCES.indexOf(source) !== -1) return source; 137 if (source.indexOf("2gis") !== -1) return "2gis"; 138 return null; 139} 140 141function resolveTrackingSource(urlParams) { 142 const fromUtm = normalizeTrackingSource(urlParams.get("utm_source")); 143 if (fromUtm) { 144 setTrackingCookie(ASYR_SRC_COOKIE, fromUtm, ASYR_SRC_DAYS); 145 return fromUtm; 146 } 147 148 if (is2gisReferrer(document.referrer)) { 149 setTrackingCookie(ASYR_SRC_COOKIE, "2gis", ASYR_SRC_DAYS); 150 return "2gis"; 151 } 152 153 return normalizeTrackingSource(getTrackingCookie(ASYR_SRC_COOKIE)); 154} 155 156window.updateTrackingLinks = updateTrackingLinks; 157 158$(document).ready(function () { 159 updateTrackingLinks(); 160 setTimeout(updateTrackingLinks, 1000); 161});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.