less than a minute read • Updated 2 hours ago
Set up Google consent mode for customer tracking
How to require customer consent before Google tracking runs on the cart, checkout, and receipt.
If you need customer consent before tracking (for example for GDPR), enable consent mode. Google's consent state is then set to denied by default, and it waits for you to grant it.
Enable it
Where you set consent depends on your integration:
Google Tag (GA4 / Google Ads): turn on Require consent before tracking customers in the legacy admin (admin.foxycart.com), within the Google Tag configuration on the template configuration page. This option is not available in the new admin.
Google Tag Manager: the checkbox does not apply. Configure consent inside your Google Tag Manager interface instead.
How it works
When enabled, these defaults are set when the tracker loads on the full-page cart, checkout, and receipt:
javascript
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied',
'wait_for_update': 500
});wait_for_update gives you a 500 millisecond window to grant consent before any tracking runs.
Grant consent
When the customer gives permission, update the relevant values to granted:
javascript
gtag('consent', 'update', {
'ad_storage': 'granted',
'ad_user_data': 'granted',
'ad_personalization': 'granted',
'analytics_storage': 'granted'
});Notes
No consent prompt is shown for you. Use your own consent manager and make sure the
grantedstate is set after consent is given.On a
*.foxycart.comsubdomain, collect consent on the cart, checkout, and receipt specifically. On a custom subdomain that matches your website, you can detect consent from your own domain.