Webflow sync, pageviews & more.
NEW

How can I implement a cookie consent modal window using the Insite tool in Webflow and properly configure the callback hook to allow users to opt out of using cookies?

TL;DR
  • Sign up at Insite, create a site, customize your cookie modal, and copy the provided script.
  • Paste the Insite script into Webflow’s Project Settings under "Before tag" and publish.
  • Use the onConsentChange hook to detect consent changes and disable tracking accordingly.
  • Wrap analytics scripts in conditional checks to only load them if the user has given proper consent.

To add a cookie consent modal in Webflow using the Insite tool and configure the callback hook for opt-outs, follow these steps:

1. Sign Up and Configure Insite

  • Visit Insite and create an account.
  • In the dashboard, create a new site and customize your cookie consent modal (edit text, categories, styles).
  • From the integration settings, copy the Insite script provided for Webflow.

2. Add the Insite Script into Webflow

  • Open your Webflow project.
  • Go to Project Settings → Custom Code.
  • Paste the Insite script inside the Before tag section.
  • Save and Publish your site to test the modal.
  • Insite provides a JavaScript callback hook called onConsentChange() to monitor and react to a user’s consent changes.

  • Return to Project Settings → Custom Code → Before tag, and below the Insite script, add a small script to handle the callback. For example:

  • Enable/disable cookies based on consent by checking categories the user has approved.

  • Example (can't use raw code block):

    Use Insite's global object like:

    insite.onConsentChange(function (consent) { if (!consent.analytics) { /_ disable tracking _/ } });

  • Replace /* disable tracking */ with the app-specific code to disable triggered analytics (like turning off Google Analytics or similar scripts).

  • Wrap marketing or analytics scripts (e.g. Google Analytics) in a conditional block.
  • Add a check within the same onConsentChange function to prevent those scripts from running unless consent is given.
  • If using Webflow's Embed element on pages, consider deferring the loading of these scripts until after consent is confirmed.

Summary

To implement a cookie modal in Webflow using Insite:

  • Embed the Insite script in your Webflow project.
  • Use the onConsentChange hook to monitor and act on user preferences.
  • Conditionally load cookies or tracking scripts based on the user's opt-in category choices.

This setup ensures compliance while offering users the ability to manage their tracking preferences dynamically.

Rate this answer

Other Webflow Questions