// Capture GCLID and store in cookie function getGCLID() { const urlParams = new URLSearchParams(window.location.search); const gclid = urlParams.get('gclid'); if (gclid) { // Store in cookie for 90 days document.cookie = `gclid=${gclid}; max-age=7776000; path=/`; } return gclid || getCookie('gclid'); } function getCookie(name) { const value = `; ${document.cookie}`; const parts = value.split(`; ${name}=`); if (parts.length === 2) return parts.pop().split(';').shift(); } // Populate hidden GCLID field when form loads window.addEventListener('load', function() { const gclidValue = getGCLID(); if (gclidValue) { // Find the GCLID field and populate it const gclidField = document.querySelector('input[name="gclid"]'); if (gclidField) { gclidField.value = gclidValue; } } });