Skip to content

Analytics and consent

Analytics run in the browser only, through Google Tag Manager, and only when NEXT_PUBLIC_GTM_ID is set. Unset, nothing loads.

choices

Page load

Consent Mode v2 default:
all denied

Cookie banner

consent update
(analytics, marketing)

Saved in the browser,
restored on return

  • Consent Mode v2 starts with ad_storage, ad_user_data, ad_personalization and analytics_storage all denied.
  • The cookie banner offers necessary, analytics, marketing and preferences. The visitor’s choice updates Consent Mode and is stored in the browser (magenx_cookie_consent).
  • A footer link reopens the preferences at any time.
  • Events are pushed to the data layer regardless; consent decides whether Google may store cookies. That is how Consent Mode v2 is meant to work.
Cookie Preferences dialog: necessary cookies always active, switches for analytics, marketing and preference cookies, and Decline All, Save My Choices and Accept All buttons
Cookie preferences, reopened from the footer link.

The cookie policy page lists the cookies the site really sets, from the GDPR module’s cookie registry, and consent decisions can be logged there for audit.

EventWhen
view_item_listA tracked product list renders or changes (page, sort, filter, tab).
select_itemA product card is clicked in a tracked list.
view_itemA product page is viewed.
add_to_cart / remove_from_cartAdd to cart; quantity changes on the cart page.
view_cartThe cart page opens with items (once per visit).
add_to_wishlistA product is added to the wishlist.
begin_checkoutCheckout opens with items (once).
add_shipping_infoThe shipping step is saved (shipping_tier = method code).
add_payment_infoThe payment step is saved, including before the PayPal redirect (payment_type = method code).
purchaseThe order confirmation page (once per order).
searchA search results page for a new term.
login / sign_up / logoutSign-in (method: password or social), registration, sign-out.

purchase carries transaction_id, value, currency, tax, shipping, coupon and items[]. List events carry item_list_id and item_list_name (fixed English names such as search_results or category_<id>) and each item’s position.

LCP, CLS, INP, FCP and TTFB from real visitors are sent to GA4 (web_vitals event). For the same field data without GTM, turn on Cloudflare Web Analytics for the shop domain (Analytics & Logs > Web Analytics): it measures at the edge and needs no code in the storefront.

The tracking helpers are in apps/theme/src/lib/analytics/gtag.ts; the components in Components: Analytics.