Cookie Consent and Google Analytics

Hello,

I have a question about cookie consent and Google Analytics for my client’s Shopify store.

We use a cookie consent banner. But when visitors click “accept”, sometimes Google Analytics does not track their visit. Some conversions or page views are missing.

Is this a common problem with Shopify? Should I change any settings in the theme or the consent app? Do I need to set up Google Consent Mode, or check Google Tag Manager?

What is the best way to make sure Google Analytics tracks only after visitors accept cookies, and works well?

Thank you for any help!

you are absolutely right. setting up the consent mode is important. it helps you to communicate user cookies consent status to google. and based on the same, the tag (or pixels) will adjust their behavior so that they respect the user’s choice.

also, as you might be doing this for your shopify store, technically this may get a bit challenging.

as an alternative, go with a Google Ads conversion pixel app like Nabu for Google Ads pixel. allows you implement google tags with just a few clicks, supports visitor consent tracking, and provides accurate conversion tracking for all major events.

Some people block tracking with browser or any extension like adblocker.

Dificult to say what actually happen on your store without testing.

This issue is typically caused by tag sequencing under Consent Mode v2.

Your GA4 tag is likely firing before the consent banner updates the analytics storage setting.

To fix it:

  • Fire GA4 on Consent Initialization.

  • Set analytics storage to ‘denied’** by default.

  • Send a consent update once cookies are accepted.

I ran an audit of my GA4 setup with GAfix.ai and found my tag firing sequence was slightly off. Once corrected, the reporting recovered immediately. You can use any audit tool to check tag timing and consent signals. It saves a lot of manual debugging.

this is almost always a tag firing sequence issue. your GA4 tag is probably loading before the consent banner updates the analytics_storage signal, so it runs in denied mode even after the user clicks accept.

the fix is making sure GA4 fires on a consent update trigger (not page load) so it picks up the “granted” state. if you’re using shopify’s built-in privacy API, listen for the visitorConsentCollected event before initializing your tags.

Hey @Diana_Stanescu .

Hope you are having a good day !

I totally agreed with u, it’s a very common issue that every person faces.

Usually, the cookie banner and GA are not properly linked.

To fix it
Turn on Google Consent Mode v2 in your cookie app.
Run GA through Google Tag Manager set to fire only after acceptance.
Test with GTM preview mode.

Two answers above say this is tag sequencing and they’re partly right, but there’s a Shopify specific piece underneath that changes what you should check.

On Shopify, window.Shopify.customerPrivacy loads asynchronously. If your GA4 tag reads consent state at page load it can run before that API exists at all, and what happens next depends entirely on how your setup handles “I don’t know yet”. Some setups treat unknown as granted and fire anyway, which is the opposite of what you want. Others treat it as denied and then never re-evaluate once the answer arrives. That second one produces exactly your symptom: the visitor clicks accept, and nothing ever re-runs.

So instead of only checking tag order, check what happens in the gap before the privacy API is ready, and whether anything is listening for consent arriving late.

The event to listen for on the main page document is visitorConsentCollected. Worth knowing that the sandboxed visitor_consent_collected event web pixels receive does not fire for Shopify’s own default banner, which catches people out when they test with it.

One more thing, and it isn’t a bug. With analytics storage denied GA4 still sends cookieless pings, but those don’t create a session or a user. So some of your “missing visits” is consent working as designed. Before chasing the tag, find out what share of your visitors actually decline. If it’s a third, then a third of your traffic is legitimately absent from GA4 and no amount of reordering brings it back.

To narrow it down, open the site in a clean browser, accept the banner, and watch for a request to /g/collect afterwards. If accepting produces no new request at all, it’s the late arrival problem above rather than sequencing.

I work on Shopify tracking for a living, so consent behaviour is something I end up debugging more often than I’d like.