Analytics consent and customer privacy
To collect analytics about your storefront visitors, you might need to establish consent. Use Shopify's built-in cookie banner to get consent from your customers.
Configure your domains (required)
Anchor link to section titled "Configure your domains (required)"Some consent settings require setting the specific domain names for your store.
Configure your Hydrogen checkout domain
Anchor link to section titled "Configure your Hydrogen checkout domain"This keeps your customers' preferences consistent across storefronts and checkout.
- Start a checkout from your store, then copy the domain name from the checkout.
- For example,
hydrogen.shop
has a checkout domain ofcheckout.hydrogen.shop
.
- For example,
- From your Hydrogen storefront admin, go to Storefront settings > Environments and variables.
- Add a new environment variable with a key of
PUBLIC_CHECKOUT_DOMAIN
and the value of your checkout domain.- Don't include
https://
. - Apply the variable to your Production environment.
- Don't include
Add your domains to your content security policy
Anchor link to section titled "Add your domains to your content security policy"Make sure both your store and checkout domains are included in your content security policy.
This configuration is scaffolded by default with Hydrogen's Skeleton template. Check that your project includes the required domains:
Activate the Shopify cookie banner
Anchor link to section titled "Activate the Shopify cookie banner"- From your Shopify admin, go to Settings > Customer Privacy > Cookie banner.
- Select the regions where your banner should display.
- (Optional) In the Appearance section, click Customize. Make any required changes to the wording, colors, or preferences, then click Save.
- (Optional) In the Position section, choose how you want the cookie banner to be positioned.
- Click Save.
- To display the Shopify cookie banner on your site, in your Hydrogen project pass in
withPrivacyBanner: true
in theconsent
prop.
This is what the default cookie banner looks like on the Hydrogen demo store:
Set a different language for the Shopify cookie banner (Optional)
Anchor link to section titled "Set a different language for the Shopify cookie banner (Optional)"If you need to display the cookie banner in a different language, then specify the country and language in the consent config:
Troubleshooting
Anchor link to section titled "Troubleshooting"If the cookie banner doesn't display, then check the following:
- The cookie banner won't work on default Oxygen URLs (
*.myshopify.dev
). Run the project locally or assign a domain to your Oxygen project. - Ensure your region is selected in Settings > Customer Privacy > Cookie banner > Regions.
- Ensure that your checkout domain is set correctly.
- Ensure that your content security policy is configured correctly.
- Ensure that you've added the
withPrivacyBanner: true
option to yourAnalytics.Provider
.