I have a react gatsby site and I'm using the gatsby-plugin-gdpr-cookies plugin.
This is in my gatsby-config:
{
resolve: "gatsby-plugin-gdpr-cookies",
options: {
googleAnalytics: {
trackingId: "", // Google Analytics Property ID
cookieName: "", // Cookie name
anonymize: true, // Anonymize IP addresses (required by German privacy law)
allowAdFeatures: false, // Collect user information for ad reports (audience demographics, interests)
},
environments: ["production", "development"],
},
},
The consent banner comes up properly and when I hit accept, it can register that through the onAcccept parameter which makes me feel I have the consent banner set up properly. However, no data is sent to google analytics until the user goes to a new page. Once the new user goes to a new page, then both the page of site entry and the new page is registered.
I have the latest version of the plugin (v2.0.8) and from gatsby's docs "Reloading the page after setting the cookies is not required anymore". I know that I can use the intializeAndTrack function on accept, but would love to not have to do that.
And here is my cookie consent component:
<CookieConsent
// debug
// enableDeclineButton
disableStyles
location="bottom"
buttonClasses="cc-button"
buttonWrapperClasses="cc-button-wrap"
declineButtonClasses="cc-button-no"
containerClasses="cc-container"
contentClasses="cc-content"
buttonText="Accept"
ariaAcceptLabel="Accept"
declineButtonText="Reject"
ariaDeclineLabel="Reject"
cookieName="gil-gdpr-google-analytics"
>
We use cookies to enhance site navigation, analyze site usage, and
support our marketing efforts. By accepting cookies, you are allowing
them to be stored on your device.
</CookieConsent>