apps/storefront/src/lib/analytics/ and are designed to fire only after the visitor opts in. This page lists every helper, the built-in event categories, the PII rules that protect customer data, and how to add a new event safely.
Helper API
Import helpers fromapps/storefront/src/lib/analytics/ and use them in your storefront components.
Built-in event categories
The storefront fires the following event types automatically when consent is granted:Purchase event details
The purchase event follows stricter pseudonymization rules than other events:- The Matomo payload uses a pseudonymized order id, never the raw backend identifier.
- If
NEXT_PUBLIC_GTM_IDis configured, the GTM payload receives the merchant-facingdisplay_id. - For logged-in customers,
user_idis a hashed customer id. It is never the raw id, email, or name. - The event fires only on the order confirmation page. If the visitor refreshes or returns from a payment provider, deduplication prevents a second count.
PII rules
Every analytics payload is filtered before it leaves the browser. The following data is never sent to Matomo or GTM:- Email addresses, names, or postal addresses
- Raw customer ids or raw order ids
- JWTs, session tokens, or authentication headers
- Card or payment instrument data
- Unrestricted query strings that may contain tokens or PII
pushMatomoCommand for low-level calls so the consent gate and filters remain active.
Consent gating
Matomo is completely disabled before opt-in:- No Matomo tracking script loads.
- No tracking request fires.
- No
_pk_*cookie is set.
useHasAnalyticsConsent() or rely on pushMatomoCommand, which no-ops safely when consent is missing.
Add an event for a new feature
1
Import the helper
Import
trackCustomEvent, pushMatomoCommand, or another helper from apps/storefront/src/lib/analytics/.2
Gate on consent
Wrap the call with
useHasAnalyticsConsent() or use pushMatomoCommand, which no-ops automatically when consent is not granted.3
Fire on user action
Call the helper inside the event handler or effect that responds to the visitor interaction.
4
Verify in Matomo
Open your Matomo real-time visits view and confirm the event appears after the action is performed.
Reference
Storefront analytics
Overview of the Matomo integration, consent banner, and dashboard setup in Vulpy Commerce.
GTM and GA4
Layer Google Tag Manager and GA4 on top of the built-in Matomo pipeline.