// https://github.com/crealime/hide-phone-num/blob/master/hide-phone-num.js /*function isEmpty(str) { if (str.trim() == '') return true; return false; }*/ jQuery(function($) { $(document).ready(function() { //console.log(Cookies.get()); //console.log('Active platforms: ', wp_conversion_tracking_vars.convtrack_platforms); //console.log('Anal: ', wp_conversion_tracking_vars.status_analytics); //console.log('Metrika: ', wp_conversion_tracking_vars.status_metrika); //console.log('Metrika: ', wp_conversion_tracking_vars.metrika_counter); // console.log('FB: ', wp_conversion_tracking_vars.status_fbpixel); //console.log('Var word_mask: ', wp_conversion_tracking_vars.word_mask); //console.log('Var custom_icon: ', wp_conversion_tracking_vars.custom_icon); //console.log('Var digits_number: ', wp_conversion_tracking_vars.digits_number); //console.log('Var phone_1: ', wp_conversion_tracking_vars.phone_1); //console.log('Var phone_2: ', wp_conversion_tracking_vars.phone_2); //console.log('Var phone_3: ', wp_conversion_tracking_vars.phone_3); //console.log('Phone 1', wp_conversion_tracking_vars.phone_1); //console.log('Phone 2', wp_conversion_tracking_vars.phone_2); //console.log('Phone 3', wp_conversion_tracking_vars.phone_3); // Function to prepare numbers for use in URLs var sanitizePhone = function(phone) { myRegex = /[\s-\(\()]/g, telNewNum = phone.replace(myRegex, ''); return telNewNum; }; var digits_number = wp_conversion_tracking_vars.digits_number; $.fn.hidePhoneNum = function(options) { var settings = $.extend({ showNumber: digits_number }, options); // Form correct tel link from international format phone return this.each(function() { var telNum = $(this).data("tel"), htmlNum = $(this).html(), myRegex = /[\s-\(\()]/g, telNewNum = telNum.replace(myRegex, ''); var spocPhoneID = $(this).attr('class').split(' ').pop(); //console.log('spocPhoneID: ', spocPhoneID); //console.log('telNum: ', telNum); //console.log('telNewNum: ', telNewNum); // Action when user click for phone mask $(this).html(telNum.substr(0, settings.showNumber) + htmlNum); $(this).find('.spoc-placeholder').on('click', function(e) { e.preventDefault(); $(this).parent().html('' + telNum + ''); // Set cookies if (spocPhoneID == 'spoc-phone-1') { Cookies.set('spoc-1', 'showphone', { expires: 30 }); } else if (spocPhoneID == 'spoc-phone-2') { Cookies.set('spoc-2', 'showphone', { expires: 30 }); } else if (spocPhoneID == 'spoc-phone-3') { Cookies.set('spoc-3', 'showphone', { expires: 30 }); } else if (spocPhoneID == 'spoc-phone-4') { Cookies.set('spoc-4', 'showphone', { expires: 30 }); } // Tracking click if (wp_conversion_tracking_vars.analytics_action !== null && wp_conversion_tracking_vars.analytics_action !== '') { //console.log('analytics_action: ', wp_conversion_tracking_vars.analytics_action); } if (wp_conversion_tracking_vars.metrika_action !== null && wp_conversion_tracking_vars.metrika_action !== '') { ym(wp_conversion_tracking_vars.metrika_counter, 'reachGoal', wp_conversion_tracking_vars.metrika_goal_name); } if (wp_conversion_tracking_vars.fbpixel_action !== null && wp_conversion_tracking_vars.fbpixel_action !== '') { fbq('track', wp_conversion_tracking_vars.fbpixel_action); } if (wp_conversion_tracking_vars.ga_event_category !== null && wp_conversion_tracking_vars.ga_event_category !== '' && wp_conversion_tracking_vars.ga_event_action !== '' && wp_conversion_tracking_vars.ga_event_action !== '') { gtag('event', 'send', { 'event_category': wp_conversion_tracking_vars.ga_event_category, 'event_action': wp_conversion_tracking_vars.ga_event_action }); } }); }); }; //==================== // Hiding phones functionality //==================== if (wp_conversion_tracking_vars.phone_status_1 == true) { // Append number transformation $('.spoc-phone-1').hidePhoneNum({ //showNumber: 8 }); // Check for active cookies, if it exist - remove mask if (Cookies.get('spoc-1') == 'showphone') { $(".spoc-phone-1 .spoc-placeholder").remove(); $(".spoc-phone-1").html('' + wp_conversion_tracking_vars.phone_1 + ''); } } // If phone does not filled - remove existing html wrapper code entirely else { $(".spoc-phone-1").remove(); } if (wp_conversion_tracking_vars.phone_status_2 == true) { // Append number transformation $('.spoc-phone-2').hidePhoneNum({ //showNumber: 4 }); // Check for active cookies, if it exist - remove mask if (Cookies.get('spoc-2') == 'showphone') { $(".spoc-phone-2 .spoc-placeholder").remove(); $(".spoc-phone-2").html('' + wp_conversion_tracking_vars.phone_2 + ''); } } // If phone does not filled - remove existing html wrapper code entirely else { $(".spoc-phone-2").remove(); } if (wp_conversion_tracking_vars.phone_status_3 == true) { // Append number transformation $('.spoc-phone-3').hidePhoneNum({ //showNumber: 4 }); // Check for active cookies, if it exist - remove mask if (Cookies.get('spoc-3') == 'showphone') { $(".spoc-phone-3 .spoc-placeholder").remove(); $(".spoc-phone-3").html('' + wp_conversion_tracking_vars.phone_3 + ''); } } // If phone does not filled - remove existing html wrapper code entirely else { $(".spoc-phone-3").remove(); } if (wp_conversion_tracking_vars.phone_status_4 == true) { // Append number transformation $('.spoc-phone-4').hidePhoneNum({ //showNumber: 4 }); // Check for active cookies, if it exist - remove mask if (Cookies.get('spoc-4') == 'showphone') { $(".spoc-phone-4 .spoc-placeholder").remove(); $(".spoc-phone-4").html('' + wp_conversion_tracking_vars.phone_4 + ''); } } // If phone does not filled - remove existing html wrapper code entirely else { $(".spoc-phone-4").remove(); } }); }); //==================== // Conversion Tracking Functionality //==================== // Define selected text function function getSelectedText() { var text = ""; if (typeof window.getSelection != "undefined") { text = window.getSelection().toString(); } else if (typeof document.selection != "undefined" && document.selection.type == "Text") { text = document.selection.createRange().text; } return text; } // Conversion tracking setTimeout(() => { jQuery(function(e) { e("[href='tel:+79014699363']").click(function () { ym(69630286, "reachGoal", "phoneme") fbq("track", "Lead") gtag("event", "send", { event_category: "phone", event_action: "call" }), console.log("tel click") }) e(document).bind("copy", function (e) { -1 !== getSelectedText().indexOf("+7 (969) 999 56 85") && (ym(69630286, "reachGoal", "copyphone"), fbq("track", "Lead"), gtag("event", "send", { event_category: "phone", event_action: "copy" })) }) e(document).bind("copy", function (e) { -1 !== getSelectedText().indexOf("+7 (901) 469 93 63") && (ym(69630286, "reachGoal", "copyphone"), fbq("track", "Lead"), gtag("event", "send", { event_category: "phone", event_action: "copy" })) }) e("[href='mailto:info@indiba.com.ru']").click(function () { ym(69630286, "reachGoal", "mailpush") fbq("track", "Lead") gtag("event", "send", { event_category: "mail", event_action: "push" }) }) e(document).bind("copy", function (e) { -1 !== getSelectedText().indexOf("info@indiba.com.ru") && (ym(69630286, "reachGoal", "copymail"), gtag("event", "send", { event_category: "mail", event_action: "copy" }), fbq("track", "Lead")) }) e("[href='mailto:contact@indiba.com.ru']").click(function () { ym(69630286, "reachGoal", "mailpush") fbq("track", "Lead") gtag("event", "send", { event_category: "mail", event_action: "push" }) }) e(document).bind("copy", function (e) { -1 !== getSelectedText().indexOf("contact@indiba.com.ru") && (ym(69630286, "reachGoal", "copymail"), gtag("event", "send", { event_category: "mail", event_action: "copy" }), fbq("track", "Lead")) }) e("[href='https://wa.me/79699995685']").click(function () { ym(69630286, "reachGoal", "socialclick") fbq("track", "Lead") gtag("event", "send", { event_category: "social", event_action: "click" }) }) e("[href='https://wa.me/79675550309']").click(function () { ym(69630286, "reachGoal", "socialclick") fbq("track", "Lead") gtag("event", "send", { event_category: "social", event_action: "click" }) }) e("[href='https://t.me/bostongrouprussia']").click(function () { ym(69630286, "reachGoal", "socialclick"), fbq("track", "Lead"), gtag("event", "send", { event_category: "social", event_action: "click" }) }) e("[href='https://t.me/+79675550309']").click(function () { ym(69630286, "reachGoal", "socialclick"), fbq("track", "Lead"), gtag("event", "send", { event_category: "social", event_action: "click" }) }) e(".spoc-placeholder").click(function () { ym(69630286, "reachGoal", "phoneshow"), fbq("track", "Lead"), gtag("event", "send", { event_category: "phone", event_action: "show" }) }) document.addEventListener("wpcf7mailsent", function (e) { gtag("event", "send", { event_category: "form", event_action: "Submit" }), ym(69630286, "reachGoal", "formsend"), fbq("track", "Lead") }, !1) }); }, 500);