Framer Cookie Banner
This guide walks you through integrating Dreamdata Analytics with Framer's built-in Cookie Banner component. The Cookie Banner component uses Google Consent Mode v2, making it easy to implement privacy-compliant analytics tracking.
Overview
Framer's Cookie Banner component provides a native consent management solution that:
- Stores user consent preferences in
localStorageunder the keyframerCookiesConsentMode - Integrates with Google Tag Manager via Consent Mode v2
- Supports different consent levels: Necessary, Preferences, Analytics, and Marketing
Dreamdata Analytics can be configured to respect these consent preferences, always initializing but running cookieless accordingly based on user consent.
Prerequisites
Before you begin, ensure you have:
- A Framer website with the Cookie Banner component added
- A Google Tag Manager account (required)
- Access to your Dreamdata account and API key
- Administrative access to your Framer project settings
- (Optional) Access to Framer's custom code settings for SPA tracking placement
Part 1: Framer Cookie Banner Setup
Adding the Cookie Banner Component
- In Framer, open the Insert Menu
- Search for "Cookie Banner" and drag it onto your canvas
- Add the component to every page, or preferably to a common component like a navbar or footer
Configuring Consent Options
The Cookie Banner supports different consent configurations:
| Consent Type | Google Consent Mode Mapping |
|---|---|
| Necessary | security_storage + functionality_storage |
| Preferences | personalization_storage |
| Analytics | analytics_storage |
| Marketing | ad_storage + ad_user_data + ad_personalization |
For Dreamdata Analytics, ensure the Analytics option is available for users to consent to.
Regional Settings
Configure the banner behavior for different regions:
- EU visitors: Use "Customizable" or "Accept/Reject" to comply with GDPR
- Rest of world: Can use "No Choice" for automatic acceptance, or match EU settings
Part 2: Google Tag Manager Setup
Google Tag Manager (GTM) is required for integrating Dreamdata Analytics with Framer. GTM handles the main Dreamdata initialization and consent management integration.
Create a GTM Container
- Go to Google Tag Manager
- Create a new container for your website (or use an existing one)
- Note your Container ID (format:
GTM-XXXXXXX)
Enable Consent Mode
- In GTM, navigate to Admin → Container Settings
- Enable Consent Overview
- This allows tags to respect user consent preferences
Connect GTM to Framer
- In Framer, select your Cookie Banner component
- In the properties panel, find the GTM Container ID field
- Enter your Container ID (e.g.,
GTM-XXXXXXX)
Part 3: Dreamdata Tag Configuration
Create a Custom HTML Tag
- In Google Tag Manager, click Tags → New
- Name the tag "Dreamdata Analytics"
- Select Custom HTML as the tag type
Add the Dreamdata Script
Paste the consent-aware initialization script from the setup in your Dreamdata app into the Custom HTML field.
Navigate to Dreamdata and Data Platform > Sources > JavaScript v2.0. Click "Reconfigure script" to go through a wizard on how to set up the script.
Configure Tag Triggering
- Click Triggering
- Select All Pages trigger
- Save the tag
Part 4: SPA Page Tracking
Framer websites are Single Page Applications (SPAs), which means traditional page load events don't fire during navigation. To track page views correctly, add this additional script as a separate Custom HTML tag in GTM:
Create a Page Tracking Tag
- In GTM, create another Custom HTML tag
- Name it "Dreamdata Framer Page Tracking"
- Add the following script:
<script>
(function () {
function getAnalytics() {
return window.dreamdata && window.dreamdata.initialized
? window.dreamdata
: window["dreamdata-cl"];
}
var last = location.pathname + location.search + location.hash;
function firePage() {
var analytics = getAnalytics();
if (analytics && typeof analytics.page === "function") {
analytics.page();
}
}
function checkUrlChange() {
var now = location.pathname + location.search + location.hash;
if (now !== last) {
last = now;
firePage();
}
}
["pushState", "replaceState"].forEach(function (k) {
var orig = history[k];
if (!orig) return;
history[k] = function () {
var r = orig.apply(this, arguments);
setTimeout(checkUrlChange, 0);
return r;
};
});
window.addEventListener("popstate", checkUrlChange);
window.addEventListener("hashchange", checkUrlChange);
window.addEventListener("framer:pageview", checkUrlChange);
})();
</script>
This script:
- Overrides
history.pushStateandhistory.replaceStateto detect programmatic navigation - Listens for
popstateandhashchangeevents for browser navigation - Listens for Framer's custom
framer:pageviewevent - Only fires a page view when the URL actually changes
⚠️ SPA tracking Script Warning
If you place the SPA tracking script, you are responsible for maintaining it. The script depends on Framer's internal
framer:pageviewevent and may break if Framer updates their platform.
Configure Triggering
- Set the trigger to All Pages
- Save and publish the tag
Alternative: Place SPA Script in Framer Custom Code
If you prefer, you can move the SPA page tracking script from GTM to Framer's custom code instead:
- Remove the SPA script from GTM (keep only the main Dreamdata tag in GTM)
- Access Framer Custom Code Settings
- In your Framer project, click the Settings icon
- Navigate to General → Custom Code
- Add the SPA script to "End of
<body>tag"- Paste the same SPA tracking script shown above
Consent Updates
The Dreamdata script automatically handles consent updates. When a user changes their consent preferences via the Framer Cookie Banner, the script:
- Always initializes and tracks in cookieless mode by default
- Monitors the GTM dataLayer for consent changes (
analytics_storagegranted/denied) - Switches to full tracking with cookies when analytics consent is granted
- Reverts to cookieless mode when consent is revoked (tracking continues without cookies)
No additional GTM triggers or configuration is required for consent handling.
Testing and Debugging
Enable Debug Mode
To see detailed console logs during testing, open your browser's developer console and run:
localStorage.setItem("DD_DEBUGGER", "true");
Then refresh the page. You'll see logs for:
- Consent state changes
- DataLayer updates
- Dreamdata initialization steps
Verify Consent Flow
- Clear cookies and localStorage to simulate a new visitor
- Load your Framer site - the Cookie Banner should appear
- Check the console - Dreamdata should initialize in cookieless mode
- Accept analytics cookies - Dreamdata should switch to full tracking mode
- Navigate between pages - Verify page views are tracked
Check in Dreamdata
- Log in to your Dreamdata account
- Navigate to the debugger or live events view
- Verify page views are being received from your Framer site
Summary
With this GTM-based integration, Dreamdata Analytics will:
- ✅ Always initialize and track in cookieless mode by default
- ✅ Respect consent changes in real-time
- ✅ Track page views correctly on Framer SPA navigation
- ✅ Switch between cookieless and full tracking based on consent
- ✅ Comply with GDPR and other privacy regulations
For more information about Framer's Cookie Banner, see the official Framer documentation.