MauricioRobayo / nextjs-google-analytics

Google Analytics for Next.js
MIT License
527 stars 50 forks source link

Support 'wait-for-update' when applying default consent #653

Open jesspanni opened 7 months ago

jesspanni commented 7 months ago

It's currently possible to specify a default consent which is useful in circumstances when users are required to explicitly opt-in before sending user data to GA.

<GoogleAnalytics defaultConsent='denied' />

When a user has previously given consent it's important to allow for consent preferences to be applied before tags are fired, otherwise the default consent will be used . Google gtag consent API provides a wait-for-update argument that allows time for cookie consent libraries and platforms to apply previous consent preferences before tags are fired via a call to consent.

It is not currently possible to take advantage of this feature and as a result is likely to result in initial page load analytics from not being collected.

Allowing users to specify a value via GoogleAnalyticsProps seems like a logical option.