Closed wizardlyhel closed 1 month ago
Oxygen deployed a preview of your hl-analytics-manager branch. Details: |
Storefront | Status | Preview link | Deployment details | Last update (UTC) |
---|---|---|---|---|---|
subscriptions | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 10, 2024 5:52 PM | |
third-party-queries-caching | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 10, 2024 5:52 PM | |
vite | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 10, 2024 5:51 PM | |
skeleton | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 10, 2024 5:51 PM | |
optimistic-cart-ui | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 10, 2024 5:51 PM | |
custom-cart-method | ✅ Successful (Logs) | Preview deployment | Inspect deployment | April 10, 2024 5:51 PM |
Learn more about Hydrogen's GitHub integration.
We detected some changes in packages/*/package.json
or packages/*/src
, and there are no updates in the .changeset
.
If the changes are user-facing and should cause a version bump, run npm run changeset add
to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.
so how do we implement this ? :)
@jonrrivera Please follow the readme in example https://github.com/Shopify/hydrogen/tree/main/examples/analytics
We are working on an official tutorial on shopify.dev
@wizardlyhel the analytics example that you linked above is marked unstable, is this still the case or are we ok to use this in production? I'm trying to get Google Analytics and Meta Pixel running on our Hydrogen Store. Thank you.
We are just ironing out some bugs when used with 3p consent management tools. Other than that, the api interface is fairly stable . We don't anticipate any more big changes
@wizardlyhel is there any way to test that custom pixels are actually firing?
@j-Riv You can use this as an example to see console logs when the events are firing https://github.com/Shopify/hydrogen/blob/main/examples/analytics/app/components/CustomAnalytics.tsx
Make sure to include this component in your root.tsx
within <Analytics.Provider>
@wizardlyhel I tried following the example but still unable to see any logs.
The unstable version didn't have much error warnings. The stable version will let you know what's missing. Double check the following:
PUBLIC_STOREFRONT_API_TOKEN
, PUBLIC_STORE_DOMAIN
, PUBLIC_CHECKOUT_DOMAIN
defined in your local .env
. Do not use the private token's value in place of the PUBLIC_STOREFRONT_API_TOKEN
's value. If you are testing in production, make sure PUBLIC_CHECKOUT_DOMAIN
is in the storefront's environment variables.<Analytics.Provider>
's canTrack
property, make sure this callback returns a true
at some point. If it doesn't return true, no analytics will be sent@wizardlyhel Thanks for the reply. I am following all the points but I am getting a unauthorized error in my console.log though, for this url https://checkout.hydrogen.shop/api/unstable/graphql.json
Make sure the PUBLIC_CHECKOUT_DOMAIN
in your .env
file and also in storefront custom environment variables isn't set to checkout.hydrogen.shop
but instead to the domain url of your own checkout.
If you don't know what that is, navigate to the checkout of your own store and copy that domain value and set it for PUBLIC_CHECKOUT_DOMAIN
Support for Customer Privacy API and better Analytics DX
Proposed developer experience
1. Return the consent configuration
In your
root.tsx
loader return the consent configuration2. Add the
<Analytics>
for facilitating analytics events and instrumenting page view and cart events.<Analytics>
propscanTrack
- defaults toShopify.customerPrivacy.userCanBeTracked
cart
- can be a deferred promise or an object. If this is defined, cart events will be publishedconsent
- configuration for the consent API bannershop
- can be a deferred promise or object. If this is defined, Shopify will send analyticscustomPayload
- data to be made available on any analytics events3. Add page view event for product, collection, cart, search views.
In your product route files,
4. Publish your own custom events
Anywhere within
<AnalyticsProvider>
, use theuseAnalyticsProvider
hook to give you the function to publish additional events.5. Subscribe to analytics events
Anywhere within
<AnalyticsProvider>
, use theuseAnalyticsProvider
hook to give you the function to subscribe to analytics events published within the provider.WHAT is this pull request doing?
HOW to test your changes?
Post-merge steps
Checklist