Headless Event Tracking: What Changes When You Leave the Theme Behind
You went headless. Your storefront is faster, your design is custom, your checkout is still Shopify. But when you check your analytics, half your events are missing. Product views? Gone. Add to carts? Silent. Purchases? Still there. This article explains why — and how to fix it.
The Headless Tracking Divide
When you move from a Shopify theme to a headless storefront (like Hydrogen), event tracking splits into two completely different systems:
What breaks:
- Product page views
- Collection page views
- Search events
- Add to cart
- Cart views
- Any custom storefront interactions
What survives:
- Checkout started
- Payment info submitted
- Checkout completed (purchase)
The reason is architectural: Shopify’s Customer Events (web pixels) only run on Shopify-hosted pages — the Online Store theme and the checkout. Your custom Hydrogen storefront is your own React app, hosted elsewhere, so Shopify’s pixel system never loads there.
This means:
- If you installed pixels via Settings → Customer Events, they fire on checkout but not on your storefront
- Your storefront events need a completely different setup — either Hydrogen’s built-in
Analyticscomponents or manual pixel scripts
How Events Travel: Two Separate Pipelines
Headless tracking uses two independent pipelines, depending on where the event happens:
Pipeline 1: Storefront Events (Your React App)
When a shopper browses your Hydrogen storefront, events flow like this:
Hydrogen Component → Analytics.Provider → Shopify Monorail → Shopify Analytics
What fires:
page_rendered(all pages)collection_page_renderedproduct_page_renderedproduct_added_to_cartsearch_submitted
Where it goes:
- Shopify’s internal analytics (Monorail, schema
custom_storefront_customer_tracking/1.2) - Shows up in your Shopify admin Analytics reports
- Does NOT automatically go to GA4, Meta, TikTok, or any third-party platform
To get storefront events into GA4/Meta/TikTok, you have two options (covered in the next section).
Pipeline 2: Checkout Events (Shopify-Hosted)
When a shopper clicks “Checkout,” they leave your Hydrogen storefront and land on Shopify’s hosted checkout domain (checkout.yourstore.com). From this point forward:
Shopify Checkout → Customer Events (Web Pixels) → Your Pixels (GA4, Meta, etc.)
What fires:
checkout_startedcheckout_contact_info_submittedcheckout_address_info_submittedcheckout_shipping_info_submittedpayment_info_submittedcheckout_completed(purchase)
Where it goes:
- Any pixel you installed via Settings → Customer Events
- Works exactly like a theme-based store
- Purchase attribution is fully intact — you get complete checkout data even on headless
This is the good news: your conversion tracking doesn’t break. The bad news: everything before checkout needs to be rebuilt.
Two Ways to Send Storefront Events
Your Hydrogen storefront is a React app with no sandbox restrictions. You have two ways to get events into third-party platforms — and you can mix both:
Option 1: Direct Pixel Scripts (Manual)
Load Meta Pixel, gtag, or TikTok Pixel directly in your Hydrogen app, then manually fire events:
// In your product page component
fbq('track', 'ViewContent', {
content_ids: ['12345'],
content_type: 'product',
value: 29.99,
currency: 'USD'
});
// In your add-to-cart handler
fbq('track', 'AddToCart', {
content_ids: ['12345'],
value: 29.99,
currency: 'USD'
});
Pros:
- Full control over event timing and parameters
- No dependency on Hydrogen’s Analytics components
- Works with any tracking setup
Cons:
- You write every event call manually
- Easy to miss events or send inconsistent data
- You handle consent gating yourself
Option 2: Subscribe to Hydrogen’s Event Bus (Convenience Layer)
Hydrogen’s Analytics components (Analytics.ProductView, Analytics.CartView, etc.) automatically collect standard events. You can subscribe to this event bus and forward everything to your platforms:
import { useAnalytics } from '@shopify/hydrogen-react';
function AnalyticsListener() {
const { subscribe } = useAnalytics();
useEffect(() => {
subscribe('product_page_rendered', (event) => {
// Forward to Meta
fbq('track', 'ViewContent', {
content_ids: [event.products[0].product_id],
value: event.products[0].price,
currency: event.currency
});
// Forward to GA4
gtag('event', 'view_item', {
items: event.products,
value: event.total_value,
currency: event.currency
});
});
}, []);
}
Pros:
- Hydrogen collects the data for you (page views, cart contents, product details)
- One central place to forward events to multiple platforms
- Consistent event structure
Cons:
- Only works if you use Hydrogen’s
Analyticscomponents - If you’re not using
Analytics.ProductView, there’s nothing to subscribe to - Still need to handle consent gating
Best practice: Use both. Standard events (page views, add to cart) go through subscribe(). Custom interactions (video plays, form submissions) are fired manually.
Need help figuring out which events to track? Fill out your custom event spec sheet →
Consent: The Hard Gate
Here’s the critical part most guides skip: Hydrogen’s Analytics components check consent before firing anything.
From the Hydrogen source code (analytics.ts):
if (!payload.hasUserConsent) return Promise.resolve();
If you haven’t configured consent, zero events fire. No page views, no add to carts, nothing. This is by design — Shopify enforces privacy compliance at the framework level.
The Official Consent Setup (5 Steps)
Shopify’s recommended approach uses the Customer Privacy API with a native cookie banner:
-
Assign a checkout subdomain — Point
checkout.yourdomain.comto your Online Store (Settings → Domains → Target: Online Store, Type: Primary). This ensures consent cookies are shared between your Hydrogen storefront and Shopify checkout. -
Add environment variable — In Storefront settings → Environments and variables, add
PUBLIC_CHECKOUT_DOMAIN(withouthttps://), apply to Production. -
Configure CSP — Your Content Security Policy must include your store and checkout domains (Hydrogen skeleton includes this by default).
-
Enable the cookie banner — Settings → Customer Privacy → Cookie banner. Choose regions, customize appearance and text.
-
Turn it on in code — Pass
withPrivacyBanner: truetoAnalytics.Provider:
<Analytics.Provider
shopId="your-shop-id"
consent={{
withPrivacyBanner: true,
country: 'US',
language: 'en'
}}
>
{/* your app */}
</Analytics.Provider>
No Double Consent
Here’s the elegant part: consent is shared between your Hydrogen storefront and Shopify checkout. When a customer accepts cookies on your storefront, they don’t see the banner again at checkout.
The mechanism:
- Shopify stores consent in an HTTP-only cookie on your store domain
- The checkout subdomain setup (step 1) ensures both interfaces share the same cookie
- Regional settings (EEA, UK, etc.) apply uniformly to both
If you skip the checkout subdomain setup, consent doesn’t carry over — and customers see the banner twice. This is why the 5-step setup isn’t optional.
Alternative Consent Solutions
- Third-party CMPs — Consentmo, Pandectes, Avada all support Hydrogen + Customer Privacy API + Google Consent Mode v2
- Custom banner — Build your own consent UI, set consent state manually, gate pixel firing yourself (full flexibility, full compliance responsibility)
Shopify’s official position: “You’re responsible for ensuring that all analytics you’re sending from your Hydrogen site are compliant with consent laws.”
What Hydrogen Actually Sends (Source Code Verification)
From hydrogen-react/src/analytics-schema-custom-storefront-customer-tracking.ts, here’s what Hydrogen’s Analytics components actually track:
Events:
page_rendered— All pagescollection_page_rendered— Collection pagesproduct_page_rendered— Product pagesproduct_added_to_cart— Add to cartsearch_submitted— Search
Fields sent with each event:
Page context:
canonical_urlevent_source_url(url, path, search params, title)referreruser_agentnavigation_type
Shop/user:
shop_idcustomer_idcurrency
Products (on product/cart events):
products[]array withproduct_id,variant_id,variant_gid,sku,name,brand,category,price,quantitytotal_value
Cart:
cart_token
Privacy flags:
analytics_allowedmarketing_allowedsale_of_data_allowedgdpr_enforcedccpa_enforcedis_persistent_cookie(= hasUserConsent)
Destination: https://{shopDomain}/.well-known/shopify/monorail/unstable/produce_batch (or monorail-edge.shopifysvc.com), schema custom_storefront_customer_tracking/1.2.
This data goes to Shopify’s internal analytics. To get it into GA4/Meta/TikTok, you subscribe and forward (Option 2 above) or send manually (Option 1).
Once the events reach GA4/Meta/TikTok, they need to use the right names — see the complete event name mapping →
FAQ
Do I need to rebuild all my tracking when going headless?
Only your storefront tracking. Checkout events (checkout started, payment submitted, purchase) work exactly like a theme store — they’re handled by Shopify’s Customer Events system. But product views, add to carts, and search events need to be rebuilt using Hydrogen’s Analytics components or manual pixel scripts.
Can I just use Google Tag Manager on Hydrogen?
Yes — GTM works fine on Hydrogen. You can load the GTM script in your root layout and use GTM’s data layer to fire events. But you still need to handle consent gating yourself, and you’ll need to manually push events to the data layer (or use Hydrogen’s useAnalytics().subscribe() to forward them).
What happens if I don't set up consent?
Nothing fires. Hydrogen’s Analytics components check hasUserConsent before sending anything. If consent isn’t configured, you get zero page views, zero add to carts, zero search events. This is intentional — Shopify enforces privacy compliance at the framework level.
Do customers see the cookie banner twice (storefront + checkout)?
Not if you set it up correctly. When you assign a checkout subdomain (checkout.yourdomain.com) and configure the Customer Privacy API, consent is stored in a shared cookie. Customers accept once on your storefront, and the banner doesn’t appear again at checkout.
Can I mix manual pixel scripts with Hydrogen's Analytics components?
Absolutely. Best practice is to use Hydrogen’s Analytics components for standard events (page views, add to cart) and subscribe to forward them to your platforms. For custom interactions (video plays, form submissions), fire events manually with fbq(), gtag(), etc. Just make sure both paths respect consent.
Headless tracking architecture verified against Shopify Hydrogen documentation, Customer Privacy API docs, and hydrogen-react source code as of August 2026. Hydrogen is actively developed — if you spot anything outdated, let us know and we’ll update the article.
Information Verification
Verified: 2026-08-08