-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Analytics Provider, Customer Privacy API and Privacy Banner #1789
Conversation
packages/hydrogen/src/analytics-manager/AnalyticsProvider.productView.example.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! 🔥
packages/hydrogen/src/customer-privacy/ShopifyCustomerPrivacy.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Fran Dios <[email protected]>
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 |
@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:
|
@wizardlyhel Thanks for the reply. |
Make sure the 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 |
I am currently trying to implement this and have a few questions,
Thank you! |
We will be releasing in a day or two. That would bring the
The GTM example won't work exactly on localhost:3000 .. since the link to the gtm file isn't real. Once you replace that with your own, then it should work.
You don't have to follow that Shopify doc for customer privacy api integration. The
|
Released Official docs: https://shopify.dev/docs/storefronts/headless/hydrogen/analytics. Run Make sure to replace imports for |
Hi @wizardlyhel - I can open an issue if I need to, but when setting <Analytics.Provider
cart={data.cart}
shop={data.shop}
consent={data.consent}
customData={{foo: 'bar'}}
> I'm getting Any recommendations? Thanks! |
that indeed is a bug - please create an issue so we can track it |
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