Purpose#
GoogleTagManager.liquid contains the theme's Google Analytics (gtag) integration and consent handling.defining window.dataLayer
defining the gtag(...) function
setting a default consent state (denied)
loading gtag.js when GlobalData.Settings.googleAnalytics is configured
updating consent state based on the Cookie Manager configuration and the user's cookie preferences
Where it's used#
GoogleTagManager.liquid is rendered by the main layout:{% render 'Structure\\GoogleTagManager' %}
Google Analytics id#
GlobalData.Settings.googleAnalytics
When present, the template loads:https://www.googletagmanager.com/gtag/js?id=...
Cookie preferences#
The script reads the cookie:selected categories (e.g. analytics, advertising)
a stored consent version (prefixed as version-...)
The template attempts to locate a CookieManager component in footer components, then reads:blocks with b.toggle.cookieCategory
cookie_manager.settings.consentVersion
decide which categories are configurable
expire old consent when the version changes
Output#
The template outputs <script> tags in the page head that:initialize consent to denied
optionally load and configure GA
update consent to granted for allowed categories
It also outputs two placeholders:<script type="text/plain" data-cookie-category="analytics"></script>
<script type="text/plain" data-cookie-category="advertising"></script>
Notes#
Consent is updated only when consent has not expired and at least one category is allowed.
Keep this template in sync with Cookie Manager behavior so categories and versioning stay consistent.
Modified at 2026-05-12 09:02:19