Skip to content

Analytics Provider - ID: 60856168 #3304

@elliott-convert

Description

@elliott-convert

Which package or tool is having this issue?

Hydrogen

What version of that package or tool are you using?

"@shopify/hydrogen": "2025.4.1"

What version of Remix are you using?

Remix 2.16.1

Steps to Reproduce

Hey team, not sure how to best report this as it's a continuation of a Shopify Support Ticket with Joshua/Charlotte for Ticket Number 60856168 - We are unsure if this is an actual bug at this stage. I'll recap the Shopify Support ticket and provide some information in this section.

The issue came about when the client had reported discrepancies between GA4 and Shopify Analytics. Specifically around sessions and add to cart events.

Things we would like to confirm:

  • Are ENVs setup correctly?
  • Is Analytics Provider setup correctly?
  • Is Shopify receiving the payloads correctly?

Here’s how I’ve currently mapped out the situation for the AUNZ environments.

Environment Setup

  • Storefront → Shopify (via Monorail): Payloads are being sent and confirmed with 200 responses.
  • Checkout → Shopify: Payloads are being sent and confirmed with 200 responses.
  • Cookie Linking: Storefront and Checkout appear to be correctly linked via cookies.
  • Attribution: Awaiting confirmation from Shopify that payloads are being correctly attributed to the appropriate stores or markets.

USCA + EUUK

  • Events are currently not coming through due to the Privacy Banner → Convert to action these changes.
  • Awaiting confirmation from Shopify on whether the Headless Sales Channel supports the Shopify Analytics Provider.

Cookies

  • 09/10 – Shopify mentioned analytics tracking was impacted due to the Cookie Consent banner.
  • 10/10 – Convert replied that documentation suggests tracking should not be affected.
  • 11/10 – Shopify confirmed the Cookie Banner does not impact tracking on non-affected sites.
  • 15/10 – Convert provided additional screenshots showing cookies persist correctly as per documentation.
  • Shopify confirmed cookies are set correctly.
  • The extra _shopify_y cookie is expected due to the separate checkout domain.

Domains

  • 14/10 – Shopify mentioned environment variable domains may be incorrectly set and advised using values from Markets > Domains.
  • 15/10 – Convert sent updated screenshots for Shopify to confirm before proceeding.
  • 18/10 – Shopify confirmed the suggested values were correct.
  • 20/10 – Convert tested locally, but the suggested values did not work and affected the site.
  • 22/10 – Shopify confirmed the existing environment variable values (referencing myshopify URLs) are correct.
  • Supporting documentation also confirms that the Store Domain should be the myshopify domain under required environment variables.
  • Pending: Confirmation that the current environment variables are final and do not require further changes.

Cart Tokens

  • 18/10 – Shopify suggested the Monorail payloads were incorrect (missing shopifySalesChannel or cart_id).
  • 20/10 – Convert confirmed payload references cart_token and requested clarification on shopifySalesChannel.
  • 22/10 – Shopify noted that previous information may be outdated. cart_token may now be expected, and shopifySalesChannel is automatic and not normally visible. Shopify to confirm correct setup

Context

Store Setup

We are currently managing routing to different stores using prefixes. For example.

const locales: Record<string, I18nLocale> = {
  AU: { language: 'EN', country: 'AU', pathPrefix: '', session: 'AUNZ', market: 'au' },
  NZ: { language: 'EN', country: 'NZ', pathPrefix: '/nz', session: 'AUNZ', market: 'nz' },
  ROW: { language: 'EN', country: 'HK', pathPrefix: '/row', session: 'AUNZ', market: 'row' },
  US: { language: 'EN', country: 'US', pathPrefix: '/us', session: 'USCA', market: 'us' },
  CA: { language: 'EN', country: 'CA', pathPrefix: '/ca', session: 'USCA', market: 'ca' },
  UK: { language: 'EN', country: 'GB', pathPrefix: '/uk', session: 'UKEU', market: 'uk' },
  EU: { language: 'EN', country: 'DE', pathPrefix: '/eu', session: 'UKEU', market: 'eu' },
}

This is how we've setup our AnalyticsProvider on the root.
I have added console.logs() on the frontend to display the props we are passing into the Analytics.Provider object here -> Preview URL.

  <Analytics.Provider cart={data.cart} shop={data.shop} consent={data.consent}>
    <NostoLoadProvider>
      <BreadcrumbsProvider>
        <SanityProvider key={location.pathname} env={{ SANITY_PROJECT_ID: data.env.SANITY_PROJECT_ID, SANITY_DATASET: data.env.SANITY_DATASET ?? 'production' }}>
          <DocumentLayout {...data} hasInteracted={hasInteracted}>
            {children}
          </DocumentLayout>
        </SanityProvider>
      </BreadcrumbsProvider>
      <GTMAnalytics />
      <NostoStateResetOnNavigation />
      <PageLoadSpeedTracker />
    </NostoLoadProvider>
  </Analytics.Provider>

An example of how we have setup a ProductView event

    <Analytics.ProductView
      data={{
        products: [
          {
            id: product.id,
            title: product.title,
            price: selectedVariant?.price.amount || '0',
            vendor: product.vendor,
            variantId: selectedVariant?.id || '',
            variantTitle: selectedVariant?.title || '',
            quantity: 1,
          },
        ],
      }}
      customData={{ product }}
    />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions