How can we help you?

Our head office
Address 8 Finsbury Circus London EC2M 7EA
Careers
Learn about working with us at Grant Thornton UK
Our people
Find someone specific to speak to
Liquidations & administrations
Speak to someone about a new or existing claim
(function () { var CONFIG = { overwriteExisting: false, params: { utm_source: ['gtuk_utm_source', 'utm_source'], utm_medium: ['gtuk_utm_medium', 'utm_medium'], utm_campaign: ['gtuk_utm_campaign', 'utm_campaign'] } }; function decodeParam(value) { try { return decodeURIComponent(String(value).replace(/\+/g, ' ')); } catch (e) { return value; } } function getQueryParams() { var out = Object.create(null); var qs = new URLSearchParams(window.location.search || ''); qs.forEach(function (v, k) { out[k.toLowerCase()] = decodeParam(v); }); return out; } function findFieldsForName(fieldName) { var selectors = [ 'input[name="' + fieldName + '"]', 'input[id="' + fieldName + '"]', 'input[id^="' + fieldName + '-"]', '[data-targetproperty="' + fieldName + '"] input' ]; return document.querySelectorAll(selectors.join(',')); } function populate() { var params = getQueryParams(); var hasFields = false; // Track if any fields were found Object.keys(CONFIG.params).forEach(function (paramKey) { var value = params[paramKey.toLowerCase()]; if (!value) return; var fieldNames = CONFIG.params[paramKey]; fieldNames.forEach(function (fieldName) { var nodes = findFieldsForName(fieldName); console.log(`Found ${nodes.length} fields for ${fieldName}`); // Debug log if (nodes.length > 0) { hasFields = true; Array.prototype.forEach.call(nodes, function (el) { if (CONFIG.overwriteExisting || !el.value) { el.value = value; console.log(`Populated ${fieldName} with ${value}`); // Debug } }); } }); }); // If no fields found yet, retry after 500ms (up to 10 times) if (!hasFields) { console.log('No UTM fields found yet, retrying...'); setTimeout(populate, 500); } } // Initial run on DOM ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', populate); } else { populate(); } // Also retry on form load events (in case loader fires later) document.addEventListener('DOMContentLoaded', function() { // Poll every 500ms for up to 5s (adjust as needed) var attempts = 0; var maxAttempts = 10; // ~5s total var interval = setInterval(function() { attempts++; populate(); if (attempts >= maxAttempts) { clearInterval(interval); console.log('UTM population retries exhausted'); } }, 500); }); })();