<!-- Insert this script before the closing tag </body> --> <!-- The {wz_metric} token is used for substituting the Analytics code. Make sure that the token and the text in which it is written are separated by at least one space character. --> <script> (function () { function ChangeLinkWA() { this.text = "Здравствуйте! Номер моей заявки: {wz_metric}"; this.cookieSource = "_comagic_"; this.prefix = "CM-"; } ChangeLinkWA.prototype.editLink = function (url, id) { var analyticsСode = this.prefix.toString()+id.toString() if (decodeURIComponent(url.split("text=")[1]) === this.text.replace(/{wz_metric}/gi, analyticsСode)) return; var regexNumberPhone = /\d+/; if (!regexNumberPhone.test(url)) return; var phone = url.match(regexNumberPhone)[0]; var host = url.split(phone)[0]; var newUrl = host === "https://wa.me/" ? host.toString()+phone.toString()+"?text="+this.text.replace(/{wz_metric}/gi, analyticsСode) : host.toString()+phone.toString()+"&text="+this.text.replace(/{wz_metric}/gi, analyticsСode); return newUrl; }; ChangeLinkWA.prototype.getCookie = function (name) { var allCookies = this.getAllCookies() var comagicCookieName = (allCookies.filter(cookieName => cookieName.includes(name)))[0]; if (!comagicCookieName) return; var matches = document.cookie.match(new RegExp("(?:^|; )"+comagicCookieName.replace(/([.$?*|{}()[]\/+^])/g, "\\\")+"=([^;]*)")); return matches && decodeURIComponent(matches[1]); }; ChangeLinkWA.prototype.getAllCookies = function () { var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/); for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); } return aKeys; }; ChangeLinkWA.prototype.censusLinks = function () { var links = document.querySelectorAll('[href*="//wa.me"], [href*="//api.whatsapp.com/send"], [href*="//web.whatsapp.com/send"], [href^="whatsapp://send"]'); var id = this.getCookie(this.cookieSource); var that = this; links.forEach(function (link) { var newLink = that.editLink(link.href, id); if (newLink) link.href = newLink; }); }; window.addEventListener("DOMContentLoaded", function () { if (!(window.__wz_scripts && window.__wz_scripts.scriptsChangeLinkWA)) { if (!window.__wz_scripts) window.__wz_scripts = {}; window.__wz_scripts.scriptsChangeLinkWA = new ChangeLinkWA(); var interval = setInterval(function () { var id = window.__wz_scripts.scriptsChangeLinkWA.getCookie( window.__wz_scripts.scriptsChangeLinkWA.cookieSource ); if (id) { clearInterval(interval); window.__wz_scripts.scriptsChangeLinkWA.censusLinks(); } }, 200); } }); })(); </script>
CoMagic Script Code
- Step 1: Connect the Messenger
- Step 2: Connect Wazzup to CRM
- Step 3: Pay for the subscription
- Set up automation
- Useful little trinkets: it works without them, but better with them