(function(){ 'use strict'; var STORAGE_DAYS = 365; var STORAGE_SECONDS = STORAGE_DAYS * 24 * 60 * 60; var GOOGLE_ADS_UPLOAD_TZ = 'Etc/GMT+5'; var GOOGLE_ADS_OFFSET = '-05:00'; var CONVERSION_ACTION_NAME = 'Form Submit'; var DEFAULT_CONVERSION_VALUE = '0'; var DEFAULT_CONVERSION_CURRENCY = 'USD'; var CLEAN_URL_AFTER_CAPTURE = true; var CLEAN_URL_DELAY_MS = 1200; var acquisitionKeys = ["utm_source","utm_medium","utm_campaign","utm_adgroup","utm_id","utm_source_platform","utm_term","utm_content","utm_creative_format","utm_marketing_tactic","gclid","gbraid","wbraid","dclid","msclkid","fbclid","li_fat_id","ttclid","twclid","scclid","irclickid","epik","_ef_transaction_id","redditclid","campaign_id","campaign_name","adgroup_id","adgroup_name","ad_id","ad_name","creative_id","creative_name","keyword_id","keyword_text","matchtype","network","placement","placement_id","device","audience_id","audience_name","experiment_id","experiment_name","variant","landing_variant","funnel_stage","goal","objective","offer_id","promo_code","product","channel","publisher","site_source","geo","region","city","language","partner_id","partner_name","affiliate_id","affiliate_name","creator_id","creator_name","newsletter_id","send_id","list_id","message_id","message_type"]; var hiddenFields = ["site","form_name","submission_id","original_request_id","original_request_form","original_request_page","page_url","landing_page","referrer","utm_source","utm_medium","utm_campaign","utm_adgroup","utm_term","utm_content","gclid","gbraid","wbraid","msclkid","fbclid","li_fat_id","visit_time","time_to_convert","timezone","ip_address","user_agent","spam_flag","spam_score","spam_reason","honeypot_status","duplicate_check","first_landing_page","first_referrer","first_visit_time","local_time_zone","browser_language","screen_size","device_type","submitted_at","conversion_time_iso","google_ads_conversion_time","microsoft_ads_conversion_time_utc","conversion_action","conversion_value","conversion_currency","first_utm_source","first_utm_medium","first_utm_campaign","first_utm_adgroup","first_utm_id","first_utm_source_platform","first_utm_term","first_utm_content","first_utm_creative_format","first_utm_marketing_tactic","utm_id","utm_source_platform","utm_creative_format","utm_marketing_tactic","first_gclid","first_gbraid","first_wbraid","first_dclid","first_msclkid","first_fbclid","first_li_fat_id","first_ttclid","first_twclid","first_scclid","first_irclickid","first_epik","first_ef_transaction_id","first_redditclid","dclid","ttclid","twclid","scclid","irclickid","epik","_ef_transaction_id","redditclid","first_campaign_id","first_campaign_name","first_adgroup_id","first_adgroup_name","first_ad_id","first_ad_name","first_creative_id","first_creative_name","first_keyword_id","first_keyword_text","first_matchtype","first_network","first_placement","first_placement_id","first_device","campaign_id","campaign_name","adgroup_id","adgroup_name","ad_id","ad_name","creative_id","creative_name","keyword_id","keyword_text","matchtype","network","placement","placement_id","device","order_id","dedupe_id","first_name","last_name","company_name","role","phone","service_needed","custom_selection","custom","custom_entry","files","final_landing_page","final_referrer","time_to_convert_seconds","browser","os","submitted_at_local","submitted_at_utc","conversion_status","conversion_time","offline_upload_status","offline_upload_time_utc","offline_upload_error","ip_country","ip_region","ip_city","lead_status","qualification_status","spam_status","risk_score","risk_level","duplicate_status","rate_limit_status","turnstile_status","recaptcha_status","hcaptcha_status","email_valid","email_risk_score","phone_valid","phone_risk_score","ip_risk_score","ip_proxy","ip_vpn","ip_tor","ip_datacenter","ga_client_id","ga_session_id","fbc","fbp","ttp","meta_event_id","uet_event_id","tiktok_event_id","hashed_email_sha256","hashed_phone_e164_sha256","audience_id","audience_name","experiment_id","experiment_name","variant","landing_variant","funnel_stage","goal","objective","offer_id","promo_code","product","channel","publisher","site_source","geo","region","city","language","partner_id","partner_name","affiliate_id","affiliate_name","creator_id","creator_name","newsletter_id","send_id","list_id","message_id","message_type","traffic_source_summary","google_click_status","microsoft_click_status","meta_click_status","linkedin_click_status","tiktok_click_status","offline_upload_time","notes"]; var aliasMap = {"first_name":{"source":"name","transform":"firstName"},"last_name":{"source":"name","transform":"lastName"},"company_name":{"source":"field_b8a8716"},"role":{"source":"field_4f10a66"},"phone":{"source":"field_345496d"},"service_needed":{"source":"field_0225b61"},"custom_selection":{"source":"referral_source"},"custom":{"source":"referral_other_comments"},"custom_entry":{"source":"referral_other_comments"}}; function firstKey(key){ return key === '_ef_transaction_id' ? 'first_ef_transaction_id' : 'first_' + key; } function normalize(value){ return String(value == null ? '' : value).trim(); } function safeLocalGet(name){ try { return localStorage.getItem(name) || ''; } catch(e){ return ''; } } function safeLocalSet(name, value){ try { localStorage.setItem(name, value); } catch(e){} } function getCookie(name){ try { var prefix = name + '='; var parts = document.cookie ? document.cookie.split('; ') : []; for (var i = 0; i < parts.length; i += 1) if (parts[i].indexOf(prefix) === 0) return decodeURIComponent(parts[i].slice(prefix.length)); } catch(e){} return ''; } function setCookie(name, value){ value = normalize(value); if (!value) return; try { var cookie = name + '=' + encodeURIComponent(value) + '; path=/; max-age=' + STORAGE_SECONDS + '; SameSite=Lax'; if (location.protocol === 'https:') cookie += '; Secure'; document.cookie = cookie; } catch(e){} } function store(name, value, overwrite){ value = normalize(value); if (!value) return; if (!overwrite && (safeLocalGet(name) || getCookie(name))) return; safeLocalSet(name, value); setCookie(name, value); } function getStored(name){ return safeLocalGet(name) || getCookie(name) || ''; } function getTZ(){ try { return Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'; } catch(e){ return 'UTC'; } } function pad(value){ return String(value).padStart(2, '0'); } function isoUtc(ms){ try { return new Date(Number(ms)).toISOString(); } catch(e){ return ''; } } function isoLocal(ms){ try { var d = new Date(Number(ms)); return isNaN(d.getTime()) ? '' : d.toLocaleString() + ' (' + getTZ() + ')'; } catch(e){ return ''; } } var uploadFormatter = new Intl.DateTimeFormat('en-GB', { timeZone: GOOGLE_ADS_UPLOAD_TZ, year:'numeric', month:'2-digit', day:'2-digit', hour:'2-digit', minute:'2-digit', second:'2-digit', hour12:false }); function googleAdsTime(ms){ try { var parts = Object.fromEntries(uploadFormatter.formatToParts(new Date(Number(ms))).map(function(p){ return [p.type, p.value]; })); return parts.year + '-' + parts.month + '-' + parts.day + ' ' + parts.hour + ':' + parts.minute + ':' + parts.second + GOOGLE_ADS_OFFSET; } catch(e){ return ''; } } function microsoftTime(ms){ try { var d = new Date(Number(ms)); return d.getUTCFullYear() + '-' + pad(d.getUTCMonth()+1) + '-' + pad(d.getUTCDate()) + ' ' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + '+00:00'; } catch(e){ return ''; } } function diffToDHm(ms){ if (!ms || ms = 3 ? parts[2] || '' : ''; } catch(e){ return ''; } } function gaClientId(){ var ga = getCookie('_ga'); if (!ga) return ''; var parts = ga.split('.'); return parts.length >= 4 ? parts.slice(2).join('.') : ''; } function deviceType(){ var width = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0); if (width && width < 768) return 'mobile'; if (width && width 1 ? pieces.slice(1).join(' ') : ''; return name; } function clickStatus(){ return { google_click_status: (getStored('gclid') || getStored('gbraid') || getStored('wbraid') || getStored('dclid')) ? 'Captured' : 'Not Captured', microsoft_click_status: getStored('msclkid') ? 'Captured' : 'Not Captured', meta_click_status: (getStored('fbclid') || getCookie('_fbc') || getCookie('_fbp')) ? 'Captured' : 'Not Captured', linkedin_click_status: getStored('li_fat_id') ? 'Captured' : 'Not Captured', tiktok_click_status: getStored('ttclid') ? 'Captured' : 'Not Captured' }; } function trafficSummary(){ if (getStored('gclid') || getStored('gbraid') || getStored('wbraid')) return 'Google Ads / Paid Search'; if (getStored('dclid')) return 'Google Display / DV360'; if (getStored('msclkid')) return 'Microsoft Ads / Paid Search'; if (getStored('fbclid') || getCookie('_fbc') || getCookie('_fbp')) return 'Meta / Paid Social'; if (getStored('li_fat_id')) return 'LinkedIn / Paid Social'; if (getStored('ttclid')) return 'TikTok / Paid Social'; if (getStored('utm_source') && getStored('utm_medium')) return getStored('utm_source') + ' / ' + getStored('utm_medium'); var ref = (getStored('referrer') || '').toLowerCase(); if (ref.indexOf('google.') !== -1) return 'Google Organic Search'; if (ref.indexOf('bing.') !== -1) return 'Bing Organic Search'; if (ref) return 'Referral Website'; return 'Direct Website Visit'; } function capture(){ var params = new URLSearchParams(location.search); acquisitionKeys.forEach(function(key){ var value = params.get(key) || ''; if (!value && key === 'gclid') value = gclidFromGoogleCookie(); if (value) { store(key, value, true); store(firstKey(key), value, false); } }); var now = Date.now(); if (!getStored('first_visit_time')) store('first_visit_time', isoUtc(now), false); if (!getStored('first_landing_page')) store('first_landing_page', location.href, false); if (!getStored('first_referrer')) store('first_referrer', document.referrer || 'direct', false); store('landing_page', location.href, true); store('final_landing_page', location.href, true); store('referrer', document.referrer || 'direct', true); store('final_referrer', document.referrer || 'direct', true); } function populate(form){ if (!form || form.__uiAttributionBound) return; form.__uiAttributionBound = true; hiddenFields.forEach(function(key){ ensureHidden(form, key, getStored(key)); }); updateForm(form); form.addEventListener('input', function(){ updateForm(form); }, true); form.addEventListener('change', function(){ updateForm(form); }, true); form.addEventListener('submit', function(){ updateForm(form, true); }, true); } function updateForm(form, isSubmit){ var now = Date.now(); var firstVisitRaw = Date.parse(getStored('first_visit_time') || ''); var diffMs = firstVisitRaw ? now - firstVisitRaw : 0; var isThankYouPage = //thank-you/?$/i.test(location.pathname || ''); var storedSubmissionId = getStored('submission_id'); var sid = isSubmit || !getStored('submission_id') ? submissionId() : getStored('submission_id'); var originalRequestId = getStored('original_request_id') || (isThankYouPage ? storedSubmissionId : sid); var originalRequestPage = getStored('original_request_page') || (isThankYouPage ? '' : location.href); var originalRequestForm = getStored('original_request_form') || (originalRequestPage ? 'Contact Form - ' + originalRequestPage : 'Contact Form'); var status = clickStatus(); var base = { site: 'Union Impact', form_name: 'Contact Form', submission_id: sid, original_request_id: originalRequestId, original_request_form: originalRequestForm, original_request_page: originalRequestPage, dedupe_id: sid, page_url: location.href, landing_page: getStored('landing_page') || location.href, final_landing_page: location.href, referrer: getStored('referrer') || document.referrer || 'direct', final_referrer: document.referrer || getStored('referrer') || 'direct', visit_time: isoLocal(now), submitted_at: isoUtc(now), submitted_at_local: isoLocal(now), submitted_at_utc: isoUtc(now), conversion_time_iso: isoUtc(now), google_ads_conversion_time: googleAdsTime(now), microsoft_ads_conversion_time_utc: microsoftTime(now), conversion_action: CONVERSION_ACTION_NAME, conversion_value: DEFAULT_CONVERSION_VALUE, conversion_currency: DEFAULT_CONVERSION_CURRENCY, conversion_status: 'Captured', offline_upload_status: 'Not uploaded', offline_upload_time_utc: '', offline_upload_error: '', time_to_convert: diffToDHm(diffMs), time_to_convert_seconds: diffMs ? String(Math.round(diffMs / 1000)) : '', timezone: getTZ(), local_time_zone: getTZ(), browser_language: navigator.language || '', screen_size: (screen && screen.width && screen.height) ? screen.width + 'x' + screen.height : '', device_type: deviceType(), browser: browserName(), os: osName(), user_agent: navigator.userAgent || '', honeypot_status: form.querySelector('input[name="form_fields[field_831494d]"],input[name="form_fields[field_03fef6b]"],input[name="form_fields[field_bee7ed3]"]') ? 'present' : 'missing', recaptcha_status: form.querySelector('.elementor-g-recaptcha,.g-recaptcha,input[name="g-recaptcha-response"]') ? 'present' : 'missing', hcaptcha_status: form.querySelector('.h-captcha,input[name="h-captcha-response"]') ? 'present' : 'not configured', turnstile_status: form.querySelector('.cf-turnstile,input[name="cf-turnstile-response"]') ? 'present' : 'not configured', lead_status: 'New Website Lead', qualification_status: 'Not reviewed', spam_flag: 'Pending review', spam_status: 'Not checked', spam_reason: '', spam_score: '', risk_score: '', risk_level: 'Not checked', duplicate_check: 'Not checked', duplicate_status: 'Not checked', rate_limit_status: 'Not checked', email_valid: '', phone_valid: '', ip_proxy: '', ip_vpn: '', ip_tor: '', ip_datacenter: '', ga_client_id: gaClientId(), ga_session_id: '', fbc: getCookie('_fbc'), fbp: getCookie('_fbp'), ttp: getCookie('_ttp'), meta_event_id: sid, uet_event_id: sid, tiktok_event_id: sid, traffic_source_summary: trafficSummary(), google_click_status: status.google_click_status, microsoft_click_status: status.microsoft_click_status, meta_click_status: status.meta_click_status, linkedin_click_status: status.linkedin_click_status, tiktok_click_status: status.tiktok_click_status }; Object.keys(base).forEach(function(key){ ensureHidden(form, key, base[key]); }); Object.keys(aliasMap).forEach(function(alias){ var rule = aliasMap[alias]; var sourceValue = readField(form, rule.source); var value = rule.transform ? splitName(sourceValue, rule.transform) : sourceValue; ensureHidden(form, alias, value); }); acquisitionKeys.forEach(function(key){ ensureHidden(form, key, getStored(key)); ensureHidden(form, firstKey(key), getStored(firstKey(key))); }); if (isSubmit) { if (!isThankYouPage) { store('original_request_id', sid, false); store('original_request_form', 'Contact Form - ' + location.href, false); store('original_request_page', location.href, false); } store('submission_id', sid, true); } } function cleanUrl(){ if (!CLEAN_URL_AFTER_CAPTURE || !history.replaceState) return; window.setTimeout(function(){ try { var url = new URL(location.href); var changed = false; acquisitionKeys.forEach(function(key){ if (url.searchParams.has(key)) { url.searchParams.delete(key); changed = true; } }); if (changed) history.replaceState(history.state, document.title, url.pathname + (url.search ? '?' + url.searchParams.toString() : '') + url.hash); } catch(e){} }, CLEAN_URL_DELAY_MS); } function bindAll(){ capture(); document.querySelectorAll('form.elementor-form').forEach(populate); cleanUrl(); } if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', bindAll); else bindAll(); if (window.jQuery) { jQuery(window).on('elementor/frontend/init elementor/popup/show', function(){ setTimeout(bindAll, 100); }); } var observer = new MutationObserver(function(){ bindAll(); }); observer.observe(document.documentElement, { childList: true, subtree: true }); })();
Skip to content