Skip to content

feat(analytics)!: use Shopify's analytics from @shopify/hydrogen - #296

Open
rylanharper wants to merge 4 commits into
nuxt-modules:mainfrom
rylanharper:feat/hydrogen-native-analytics
Open

rylanharper wants to merge 4 commits into
nuxt-modules:mainfrom
rylanharper:feat/hydrogen-native-analytics

Conversation

@rylanharper

@rylanharper rylanharper commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

@shopify/hydrogen@2026.10 no longer re-exports the analytics helpers from @shopify/hydrogen-react. It ships Shopify's own scripts and a browser analytics bus instead. This moves the module to that API and drops @shopify/hydrogen-react. The components and composables keep their names.

🛠️ Changes

  • Load Shopify's script tags in the head. Shopify's scripts now send page views and handle consent.
  • Product, collection, search and cart views publish to the bus (window.Shopify.analytics). Cart changes use Shopify's trackCartAnalytics().
  • subscribe() and the analytics:publish hook read from the bus, so they also get cart events and page views.
  • Add POST /api/:version/graphql.json, which Shopify's consent script calls. It forwards to the storefront proxy.
  • Report events on the headless sales channel.
  • Remove the module's own sender, consent, cookie and shop lookup code (src is about 500 lines smaller).
  • Peer dependency is now @shopify/hydrogen >=2026.10.0. @shopify/hydrogen-react is dropped. CI matrix and docs updated.

⚠️ Breaking changes

  • analytics.shopId is required.
  • Removed options: autoPageView, domain, consent.checkoutDomain, consent.storefrontAccessToken, consent.banner.country, consent.banner.language. Added country.
  • storefrontId no longer attributes events (the headless channel has none).
  • subscribe and the hook receive Shopify's payload shapes, and only after consent allows tracking.
  • ShopifyCustomView and custom_* events no longer work. setShopContext() is a no-op.

🧪 Tests

  • Unit tests, typecheck, lint and pnpm check:package pass.
  • Checked by hand in playground-v4: page, collection and add-to-cart events reach Shopify.
  • e2e not run, it needs real admin credentials and store data.

🔜 Questions

  • Minor or major release?
  • Remove ShopifyCustomView, now that it does nothing?

rylanharper and others added 4 commits October 16, 2026 12:26
…rogen, add consent API route, require shopId

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ify's analytics bus

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nalytics bus

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…drogen requirement

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant