// Function to get URL parameters function getURLParameter(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^]*)"), results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } // Append UTM parameters to Brevo form document.addEventListener("DOMContentLoaded", function () { // Extract UTM parameters from the URL var utmSource = getURLParameter('utm_source'); var utmMedium = getURLParameter('utm_medium'); var utmCampaign = getURLParameter('utm_campaign'); // Locate the Brevo form iframe var brevoIframe = document.querySelector('iframe[src*="brevo"]'); if (brevoIframe) { // Get the original form URL var formSrc = brevoIframe.src; // Append UTM parameters to the URL var newSrc = formSrc + (formSrc.includes('?') ? '&' : '?') + 'utm_source=' + encodeURIComponent(utmSource) + '&utm_medium=' + encodeURIComponent(utmMedium) + '&utm_campaign=' + encodeURIComponent(utmCampaign); // Update the iframe source brevoIframe.src = newSrc; } });