Skip to main content

Consent callback

Once a visitor gives consent, activate the script by calling the optIn function.
This will also set an lio_consent key in localStorage, ensuring the script launches automatically in the future.

To make sure the Lyftio script has been fully loaded and is ready to receive the consent callback, use the following pattern:

if (window.Lyftio && Lyftio.optIn) {
// If the script is already loaded, immediately call the optIn function
Lyftio.optIn();
} else {
// If the script hasn't loaded yet, wait for the 'Lyftio::Loaded' event
window.addEventListener("Lyftio::Loaded", function () {
Lyftio.optIn();
});
}