Shopify Analytics with a storefront API frontend

Topic summary

Problem: Integrate Shopify Analytics, including Live View, into a Shopify Plus store using a custom frontend built on the Storefront API.

Early status: No documented way to enable Shopify Analytics from a headless frontend; the thread saw bumps seeking a solution.

Resolution and developments:

  • Community solution: The OP reverse‑engineered the pre‑Hydrogen analytics API and released react‑shopify‑analytics (used on sweetsideofsweden.com) to send analytics events from a custom storefront.
  • Official solution: Shopify later introduced Hydrogen React utilities, including sendShopifyAnalytics, providing an endorsed method to emit Shopify analytics from headless storefronts.

Recommendations: Prefer Hydrogen React for an official, maintained approach, unless avoiding its additional utilities/components is a priority; then the community package is a viable alternative.

Key terms:

  • Storefront API: Shopify’s API for building custom (headless) storefronts.
  • Hydrogen React: Shopify’s React library for custom storefronts, with analytics helpers like sendShopifyAnalytics.

Outcome: Resolved with clear implementation paths; no outstanding questions noted.

Summarized with AI on January 24. AI used: gpt-5.

Hey,

We’re currently running a Shopify Plus store with a custom frontend using the Storefront API. We haven’t been able to find a way to integrate Shopify Analytics into it to get the live view etc working.

This is a requirement since we’d like to get all the tracking working.

Thanks.

Going to bump this since there still doesn’t appear to be any solutions for this.

bump

This has now been resolved first by me reverse engineering the analytics API (pre-hydrogen) with the package https://github.com/sweet-side-of-sweden/react-shopify-analytics for https://www.sweetsideofsweden.com and then finally by Shopify themselves with hydrogen-react, see https://shopify.dev/docs/api/hydrogen-react/2023-04/unstable/utilities/sendshopifyanalytics

I’d recommend going with hydrogen-react unless you really want to avoid the additional utilities and components that hydrogen-react comes with :cowboy_hat_face:

1 Like