// 3. 转化追踪 const conversionIds = { main: 'AW-16834930411', secondary: 'AW-17407503475', tertiary: 'AW-17432808156', quaternary: 'AW-17459273880', analytics: 'G-4JDYGDH4FE' }; // 表单提交追踪 window.addEventListener('load', function () { document.querySelectorAll(".wpcf7-submit").forEach(function (button) { button.addEventListener("click", function (event) { var form = event.target.closest('form'); if (!form) return; var emailInput = form.querySelector('[name="Email"]'); if (!emailInput) return; var email = emailInput.value.trim().toLowerCase(); if (email === "") return; gtag('set', 'user_data', { "email": email }); gtag('event', 'Submit_Form_EC', { "send_to": conversionIds.analytics }); gtag('event', 'form_upd', { "send_to": conversionIds.analytics }); gtag('event', 'form_success', { "send_to": conversionIds.analytics }); gtag('event', 'form_submit', { "send_to": conversionIds.main }); gtag('event', 'conversion', { "send_to": conversionIds.main + '/mTkPCJ7rxJoaEOvNwts-' }); gtag('event', 'conversion', { "send_to": conversionIds.tertiary + '/tRQqCP3Cm4EbENyVzvhA' }); gtag('event', 'conversion', { "send_to": conversionIds.secondary + '/Hj5tCJ6AsPoaEPPYxexA' }); gtag('event', 'conversion', { "send_to": conversionIds.quaternary + '/_bZECMXglo0bEJjBnYVB' }); }); }); // 邮箱点击追踪 document.querySelectorAll('[onclick="sendMessageToEmail()"], a[href*="mailto:"]').forEach(function (el) { el.addEventListener('click', function () { gtag('event', 'email'); gtag('event', 'conversion', { send_to: conversionIds.main + '/5mwQCNztxJoaEOvNwts-' }); gtag('event', 'conversion', { send_to: conversionIds.secondary + '/3UT2CPWTn4EbEPPYxexA' }); gtag('event', 'conversion', { send_to: conversionIds.tertiary + '/XMPECLG1n4EbENyVzvhA' }); gtag('event', 'conversion', { send_to: conversionIds.quaternary + '/RdEUCM7glo0bEJjBnYVB' }); }); }); // WhatsApp 点击追踪 document.querySelectorAll('[onclick="sendMessageToWhatsApp()"], a[href*="api.whatsapp.com"]').forEach(function (el) { el.addEventListener('click', function () { gtag('event', 'Whatsapp'); gtag('event', 'conversion', { send_to: conversionIds.main + '/4QBSCN_txJoaEOvNwts-' }); gtag('event', 'conversion', { send_to: conversionIds.secondary + '/KILOCPiTn4EbEPPYxexA' }); gtag('event', 'conversion', { send_to: conversionIds.tertiary + '/HYRLCKu1n4EbENyVzvhA' }); gtag('event', 'conversion', { send_to: conversionIds.quaternary + '/WlukCMjglo0bEJjBnYVB' }); }); }); // 电话点击追踪 document.querySelectorAll("a[href*='tel']").forEach(function (el) { el.addEventListener('click', function () { gtag('event', 'conversion', { send_to: conversionIds.main + '/tAjiCOLtxJoaEOvNwts-' }); gtag('event', 'conversion', { send_to: conversionIds.secondary + '/E9M2CPuTn4EbEPPYxexA' }); gtag('event', 'conversion', { send_to: conversionIds.tertiary + '/AmLoCK61n4EbENyVzvhA' }); gtag('event', 'conversion', { send_to: conversionIds.quaternary + '/YVKbCMvglo0bEJjBnYVB' }); }); }); // 在线客服按钮追踪 document.querySelectorAll('[class="chat_btn_model"]').forEach(function (el) { el.addEventListener('click', function () { gtag('event', 'chatus'); gtag('event', 'conversion', { send_to: conversionIds.main + '/mXPhCOXtxJoaEOvNwts-' }); }); }); }); // 4. 邮箱变更追踪 document.addEventListener('change', function (e) { if (e.target.matches('[name="Email"]')) { gtag('set', 'user_data', { 'email': e.target.value.trim().toLowerCase() }); gtag('event', 'form_submit', { 'send_to': 'AW-16834930411' }); gtag('event', 'form_submit', { 'send_to': 'AW-17432808156' }); gtag('event', 'form_submit', { 'send_to': 'AW-17459273880' }); } }); } // gtag_report_conversion:供页面内 onclick 调用;gtag 未加载时安全返回 window.gtag_report_conversion = function (url) { if (typeof gtag !== 'function') { if (typeof url !== 'undefined') { window.location = url; } return false; } var callback = function () { if (typeof url !== 'undefined') { window.location = url; } }; gtag('event', 'conversion', { 'send_to': 'AW-16834930411/mTkPCJ7rxJoaEOvNwts-', 'event_callback': callback }); return false; }; // 探测 Google 可达性:加载 gtag.js,2.5 秒内未成功即视为不可达(未开 VPN),不加载任何 Google 脚本 var s = document.createElement('script'); s.async = true; s.src = 'https://www.googletagmanager.com/gtag/js?id=' + GA_ID; s.onload = loadGoogle; s.onerror = function () { if (!started) { s.parentNode && s.parentNode.removeChild(s); } }; document.head.appendChild(s); setTimeout(function () { if (!started) { s.onload = s.onerror = null; s.parentNode && s.parentNode.removeChild(s); } }, 50000); })();
No products found in this category.