big-lifeguard-56833
09/12/2025, 2:01 PMlively-ability-30233
09/12/2025, 2:17 PM<script>
function getParameterByName(name) {
const url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
const results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
const gclid = getParameterByName('gclid');
const fbclid = getParameterByName('fbclid');
if (gclid) {
document.cookie = 'gclid=' + gclid + '; path=/; max-age=' + 60 * 60 * 24 * 30;
}
if (fbclid) {
document.cookie = 'fbclid=' + fbclid + '; path=/; max-age=' + 60 * 60 * 24 * 30;
}
function getCookie(name) {
const value = '; ' + document.cookie;
const parts = value.split('; ' + name + '=');
if (parts.length === 2) return parts.pop().split(';').shift();
}
document.addEventListener('DOMContentLoaded', function () {
const gclidCookie = getCookie('gclid');
const fbclidCookie = getCookie('fbclid');
if (gclidCookie) {
const gclidInput = document.querySelector('input[name="gclid"]');
if (gclidInput) gclidInput.value = gclidCookie;
}
if (fbclidCookie) {
const fbclidInput = document.querySelector('input[name="fbclid"]');
if (fbclidInput) fbclidInput.value = fbclidCookie;
}
});
</script>lively-ability-30233
09/12/2025, 2:18 PM<script>
function getCookie(name) {
const value = '; ' + document.cookie;
const parts = value.split('; ' + name + '=');
if (parts.length === 2) return parts.pop().split(';').shift();
return null;
}
window.botpress.on('webchat:initialized', () => {
const gclid = getCookie('gclid') || null;
const fbclid = getCookie('fbclid') || null;
function sendClidsPayload(attempt = 0) {
try {
window.botpress.sendEvent({
type: 'custom', // nom générique d’évènement custom
payload: { gclid, fbclid } // ce que l’on veut faire remonter au bot
});
} catch (e) {
if (attempt < 20) {
setTimeout(() => sendClidsPayload(attempt + 1), 100);
}
}
}
setTimeout(() => {
window.botpress.open();
sendClidsPayload();
}, 2500);
});
</script>lively-ability-30233
09/19/2025, 8:34 AM