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#
When a Cookie Manager configures at least one category, consent is updated only when the stored consent has not expired and at least one category is allowed.
Exception — no Cookie Manager categories: when the footer has no CookieManager component, or none of its blocks sets toggle.cookieCategory, there is no consent gate. The template grants analytics and advertising storage and calls gtag('consent', 'update', ...) on every page, whatever the consent version or the _shopranos cookie holds. Add a Cookie Manager with categories if the store needs visitors to opt in.
None of the consent logic runs unless GlobalData.Settings.googleAnalytics is set; only the default denied state is emitted.
Keep this template in sync with Cookie Manager behavior so categories and versioning stay consistent.
Modified at 2026-10-07 12:02:21