Solved

Why can't I access the window.Shopify object for a cookies consent banner?

nayelyr-idem
Tourist
6 0 1

Hello! I'm trying to implement a cookies consent banner on my store (I'm using Shopify's integration with Hydrogen.). The first step is to load the customer privacy API using the window.Shopify object. However, I can't even see, much less access the Shopify property on my window object, it returns undefined. Am I missing something? 

Thank you in advance!

Accepted Solution (1)

Weaverse
Shopify Partner
70 23 30

This is an accepted solution.

Hi there, if you are using Hydrogen, I think you should take a look at this doc instead: https://shopify.dev/docs/api/hydrogen/2023-10/hooks/useshopifycookies

Helping merchants build super unique, high-performance storefronts using Weaverse + Hydrogen.
Looking for Development & Agency partners.
If you find the answer helpful, give it a thumbs up!
Our App: Theme Customizer for Shopify Hydrogen
Join our Weaverse + Hydrogen community: Weaverse Community

View solution in original post

Replies 3 (3)

Weaverse
Shopify Partner
70 23 30

This is an accepted solution.

Hi there, if you are using Hydrogen, I think you should take a look at this doc instead: https://shopify.dev/docs/api/hydrogen/2023-10/hooks/useshopifycookies

Helping merchants build super unique, high-performance storefronts using Weaverse + Hydrogen.
Looking for Development & Agency partners.
If you find the answer helpful, give it a thumbs up!
Our App: Theme Customizer for Shopify Hydrogen
Join our Weaverse + Hydrogen community: Weaverse Community
nayelyr-idem
Tourist
6 0 1

Hi! Thank you so much for replying, I didn't notice that hook! It doesn't seem like it supports all the methods from the Customer Privacy API though, like checking the user's current permissions or customize the specific type of cookies that should be enabled/disabled, for example. 

JesperUnna
Excursionist
15 0 9

Did you find a solution to this? I have exactly the same issue, trying to access window.Shopify.loadFeatures, but getting undefined for the Shopify object. Would like to listen for when the Shopify object is attached to window. Unless there is something to listen for built in to Shopify.

 

I would not consider this an accepted solution to the challenge we experience.