Connect Cromojo to your cookie banner
How to pass your visitors' cookie choices to Cromojo, with or without code
Written By David
Last updated 43 minutes ago
This guide shows you how to connect Cromojo to your cookie banner, so Cromojo follows each visitor's choice. Most banners work automatically. If yours doesn't, you need two lines of code.
Not legal advice. This article explains how Cromojo works. Whether your site needs a banner depends on where you and your visitors are. See Data Privacy & User Consent.
Step 1: Check whether you need this
Open your website's settings in Cromojo and look at First-party tracking. Your option decides what you need to do:
With the opt-in option, visitors who haven't accepted are still counted. They are tracked cookie-free, so nobody is missing from your numbers.
When you choose a Returning visitor tracking option, your tracking snippet gains a data-consent-mode attribute. If you installed Cromojo before switching, copy the updated snippet from your settings and replace the old one.
Step 2: Don't block the Cromojo script
Many banner tools let you put scripts in a category that only loads after consent. For Cromojo, you usually shouldn't:
Cookie-free only: blocking the script throws away analytics that don't need consent.
Opt-in: Cromojo already waits for consent before storing anything. If the script is blocked, it can't hear the visitor's choice.
Let the script load on every page, and connect it to your banner as shown below.
Step 3: Connect your banner
Option A: Automatic (most banners)
Cromojo reads two common consent standards by itself:
Google Consent Mode. Cromojo follows the
analytics_storagesetting. Granted means the visitor accepted. Denied means they declined.IAB TCF. Cromojo follows Purpose 1, "Store and/or access information on a device".
Most cookie banner tools can send one of these. Cookiebot, CookieYes, OneTrust, Complianz and Usercentrics all support Google Consent Mode. Turn it on in your banner tool's settings and you're done.
Option B: Manual (any other banner)
If your banner doesn't support either standard, tell Cromojo about the visitor's choice yourself. Call one of these when the visitor makes a choice:
// The visitor accepted
window.CRMJ.setConsent('granted')
// The visitor declined, or withdrew consent later
window.CRMJ.setConsent('denied')Cromojo remembers the choice, so you only need to call it when the visitor clicks a button. When a visitor declines, Cromojo removes the identifier it stored on their device.
Example: Cookiebot
<script>
window.addEventListener('CookiebotOnConsentReady', function () {
if (!window.CRMJ) return
window.CRMJ.setConsent(Cookiebot.consent.statistics ? 'granted' : 'denied')
})
</script>Example: CookieYes
<script>
document.addEventListener('cookieyes_consent_update', function (event) {
if (!window.CRMJ) return
var accepted = event.detail.accepted.indexOf('analytics') !== -1
window.CRMJ.setConsent(accepted ? 'granted' : 'denied')
})
</script>Turning off automatic detection
If you only want to use setConsent yourself, add this attribute to your Cromojo snippet:
data-consent-autodetect="false"Step 4: Test it
Open your website in a private browser window.
Open the browser console. In Chrome, press F12 and click Console.
Run this:
CRMJ.getConsentMode()It should return 'banner' (opt-in) or 'server_side' (opt-out). If it returns null, your snippet is missing the data-consent-mode attribute. Copy the snippet again from your settings.
Accept or decline in your banner, then run:
CRMJ.getConsent()It should return 'granted' after you accept and 'denied' after you decline. If it still returns null, your banner isn't reaching Cromojo. Check that Google Consent Mode is turned on, or use the manual setup.
Session recordings
If you use session recordings, the Record only after consent setting uses the same connection. It needs a Returning visitor tracking option, so Cromojo can hear the visitor's choice. Visitors whose browser sends Global Privacy Control are never recorded.
Shopify stores
Shopify's built-in cookie banner isn't detected automatically. Use the manual setup above, or a banner app that supports Google Consent Mode.
Related articles
Was this helpful?
More in Privacy & Legal
Data Privacy & User ConsentHow to Opt Out of TrackingSecurity & privacy FAQStill need help? Ask the team