Skip to content

Add a cookie consent banner to EmDash

A consent management platform (CMP) shows a cookie banner and records each visitor’s choice. To work properly it has to load before your analytics and marketing tags. With Header & Footer Code you control that order with priority: lower runs first.

Priority Snippet Placement
1 Google consent mode defaults Head
2 Your CMP’s script Head
5 Google Tag Manager loader Head
10 Google Analytics 4, other tags Head

All four go in the head, so the order within the head is what matters.

Section titled “1. Set consent mode defaults (Google tags only)”

If you use Google Analytics, Google Ads or GTM, Google’s consent mode needs default states before any Google tag loads. Add this as a snippet with Placement Head and Priority 1:

<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
ad_storage: 'denied',
ad_user_data: 'denied',
ad_personalization: 'denied',
analytics_storage: 'denied',
wait_for_update: 500
});
</script>

Many CMPs can set these defaults for you. If yours does, skip this snippet so the defaults aren’t set twice.

  1. Copy the installation script from your CMP’s dashboard. For example, CookieYes gives you a tag like this:

    <script id="cookieyes" type="text/javascript" src="https://cdn-cookieyes.com/client_data/YOUR_SITE_ID/script.js"></script>
  2. In Header & Footer Code, add it as a new snippet with Placement Head and Priority 2.

  3. Leave targeting empty so the banner shows on every page.

  4. Save, then open your site in a private window to see the banner.

Give analytics and marketing snippets a priority higher than your CMP’s, such as 5 for the GTM loader and 10 for Google Analytics.

CMPs block non-essential scripts in one of two ways:

  • Automatic blocking: the CMP scans the page and holds back known trackers. Nothing else to do.
  • Manual tagging: you mark each script with its category, usually by changing type to text/plain and adding a category attribute your CMP documents. Edit the snippet code to match.

If you have many snippets to tag, a transform can add the attribute for you based on a category stored in the snippet’s meta. The transforms page has a worked data-category example.

  • In a private window, the banner appears before any analytics request is sent. Check the Network tab in DevTools.
  • With GTM, Tag Assistant’s Consent tab shows the default and updated consent states.
  • View the page source: the consent defaults come first, then the CMP, then your tags.