Posts about

flexo wash parts washing

if (window.__knownContactEmail) { _hsq.push(['identify', { email: window.__knownContactEmail }]); _hsq.push(['trackPageView']); // pushes the identify immediately } // ADDED — Option 2: your own login/portal system. // If you have a custom login (not HubSpot Membership), expose // the logged-in user's email into a global var the same way, // e.g. from your app's server-rendered template: // window.__loggedInUserEmail = "user@example.com"; if (window.__loggedInUserEmail && !window.__knownContactEmail) { _hsq.push(['identify', { email: window.__loggedInUserEmail }]); _hsq.push(['trackPageView']); } // ADDED — Option 3: bridge from Zoho SalesIQ chat identification. // Fires whenever SalesIQ identifies a chat visitor by email — // links that identity into HubSpot's tracker too. if (window.$zoho && $zoho.salesiq && $zoho.salesiq.visitor) { $zoho.salesiq.visitor.onidentify(function (visitorInfo) { if (visitorInfo && visitorInfo.email) { _hsq.push(['identify', { email: visitorInfo.email }]); _hsq.push(['trackPageView']); } }); } // ========================================================= // Existing tracking logic — unchanged // ========================================================= function uuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } function canonicalize(url) { try { var u = new URL(url); u.hash = ''; ['utm_source','utm_medium','utm_campaign','utm_term','utm_content', 'gclid','fbclid','_hsenc','_hsmi','hsCtaTracking'].forEach(function (p) { u.searchParams.delete(p); }); var params = Array.from(u.searchParams.entries()).sort(); var qs = params.map(function (p) { return p[0] + '=' + p[1]; }).join('&'); var path = u.pathname.replace(/\/+$/, '') || '/'; return u.origin + path + (qs ? '?' + qs : ''); } catch (e) { return url; } } function loadSession() { try { var raw = localStorage.getItem(STORAGE_KEY); return raw ? JSON.parse(raw) : null; } catch (e) { return null; } } function saveSession(s) { try { localStorage.setItem(STORAGE_KEY, JSON.stringify(s)); } catch (e) {} } function newSession() { return { session_id: uuid(), start_time: Date.now(), last_activity: Date.now(), total_active_seconds: 0, pages: [], qualified: false }; } var session = loadSession(); if (!session || (Date.now() - session.last_activity) > INACTIVITY_LIMIT_MS) { session = newSession(); } var canonicalUrl = canonicalize(window.location.href); var alreadySeen = session.pages.some(function (p) { return p.url === canonicalUrl; }); if (!alreadySeen) { session.pages.push({ url: canonicalUrl, title: document.title, first_seen: Date.now() }); } session.last_activity = Date.now(); saveSession(session); function isActiveTab() { return document.visibilityState === 'visible' && document.hasFocus(); } function tick() { var s = loadSession(); if (!s) return; if ((Date.now() - s.last_activity) > INACTIVITY_LIMIT_MS) { s = newSession(); s.pages.push({ url: canonicalUrl, title: document.title, first_seen: Date.now() }); } if (isActiveTab()) { s.total_active_seconds += 1; s.last_activity = Date.now(); } saveSession(s); checkQualification(s); } setInterval(tick, 1000); function checkQualification(s) { if (s.qualified) return; if (s.pages.length >= MIN_PAGES && s.total_active_seconds >= MIN_SECONDS) { s.qualified = true; saveSession(s); fireEvent(s); } } function fireEvent(s) { var p1 = s.pages[0] || {}; var p2 = s.pages[1] || {}; var properties = { page_1_url: p1.url || '', page_1_title: p1.title || '', page_2_url: p2.url || '', page_2_title: p2.title || '', page_count: s.pages.length, session_seconds: Math.round(s.total_active_seconds), session_id: s.session_id, qualified_at: new Date().toISOString(), referrer: document.referrer || '', all_pages_json: JSON.stringify(s.pages.map(function (p) { return { url: p.url, title: p.title }; })) }; _hsq.push(['trackCustomBehavioralEvent', { name: HS_EVENT_NAME, properties: properties }]); } checkQualification(session); })();