Implement Tracking Cookie Consent
Overview
This page explains how to implement a cookie consent pop-up that allows website visitors to opt in to tracking by the Relevance Module.
When to Use
Implement cookie consent when you need to comply with privacy regulations (such as the EU "Cookie Law") that require explicit user consent for tracking cookies.
Prerequisites
- A standard Bloomreach Content project.
- The Relevance Module is installed and configured.
- You have access to edit your site's base layout template.
Implementation Steps
1. Add Cookie Consent JavaScript to the Base Layout Template
Open the file:
repository-data/webfiles/src/main/resources/site/freemarker/common/base-layout.ftl
Insert the following code just before the closing </head> tag:
<script type="text/javascript"> window.cookieconsent_options = {"message":"This website uses tracking cookies to ensure you get the best experience on our website", "dismiss":"Accept", "theme":"light-top"}; </script> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.10/cookieconsent.min.js"></script>
This code displays a pop-up bar to first-time visitors with a message about tracking cookies and an "Accept" button. When a visitor clicks "Accept," the script sets a cookie named cookieconsent_dismissed with the value yes. The Relevance Module will not track visitors until they opt in by clicking "Accept."
2. Configure the Relevance Module's Cookie Policy
Open the Console and navigate to the node:
/targeting:targeting
Add or update the following properties to enable opt-in consent and match the cookie name and value set by the script:
/targeting:targeting: targeting:consentCookieEnabled: true targeting:consentCookieOptIn: true targeting:consentCookieName: cookieconsent_dismissed targeting:consentCookieValue: yes
For details about all available configuration options, see Configure the Relevance Module's Tracking Cookie Policy.
Verification
- Visit your site as a new user (for example, in a private browser window).
- Confirm that the cookie consent pop-up appears.
- Click "Accept" and verify that the
cookieconsent_dismissedcookie is set with the valueyes. - Confirm that tracking by the Relevance Module only starts after consent is given.