By clicking “Accept all cookies,” you agree to the storage of cookies on your device to improve site navigation, analyze site usage, and support our marketing efforts. For more information, see our Privacy statement.
// Function to save the user's preference
function savePreference(id) {
const el = document.getElementById(id);
if (!el) return;
el.addEventListener("change", () => {
localStorage.setItem(id, el.checked ? "enabled" : "disabled");
console.log("Preference saved:", id, el.checked);
});
}
// Function to load an existing preference from localStorage
function loadPreference(id) {
const el = document.getElementById(id);
if (!el) return;
const value = localStorage.getItem(id);
if (value === "enabled") {
el.checked = true;
}
if (value === "disabled") {
el.checked = false;
}
}
// List of cookie toggle IDs you use in Webflow
const cookieIds = [
"cookie-essential",
"cookie-analytics",
"cookie-marketing",
"cookie-leadinfo"
];
// Load previously saved preferences on page load
cookieIds.forEach(id => loadPreference(id));
// Save the preferences whenever the toggle is changed
cookieIds.forEach(id => savePreference(id));