I'm trying to set up a gatsby site where I want to set (at least) the google analytics cookie. I have installed react-cookie-consent as well as gatsby-plugin-gdpr-cookies. My questions is:
Why does the lifetime of my cookie configured via the Cookieconsent prop always remain on "session"? when it is set to true. I tried to configure the prop expires = {365} but it doesn't work either.
Thank you!
In my Index.js :
<CookieConsent
// debug
location='bottom'
style={{ background: 'rgb(13 168 220)' }}
buttonStyle={{ background: 'rgb(148 130 110)', fontSize: '13px' }}
buttonText='Accept'
declineButtonText='decline'
expires={365}
onAccept={() => {
// alert('Accept was triggered by clicking the Accept button');
Cookies.set('gatsby-gdpr-google-analytics', 'true');
}}
enableDeclineButton
setDeclineCookie
cookieName='gatsby-gdpr-google-analytics'
This website uses cookies to enhance the user experience.See our privacy policyfor more.
In the gatsby-config.js file :
plugins: [
{
resolve: 'gatsby-plugin-gdpr-cookies',
options: {
googleAnalytics: {
trackingId: 'MY-ID', // leave empty if you want to disable the tracker
cookieName: 'gatsby-gdpr-google-analytics', // here can you change the cookie name
anonymize: true // default
},
googleTagManager: {
trackingId: 'YOUR_GOOGLE_TAG_MANAGER_TRACKING_ID', // leave empty if you want to disable the tracker
cookieName: 'gatsby-gdpr-google-tagmanager', // // here can you change the cookie name
dataLayerName: 'dataLayer' // default
},
facebookPixel: {
pixelId: 'YOUR_FACEBOOK_PIXEL_ID', // leave empty if you want to disable the tracker
cookieName: 'gatsby-gdpr-facebook-pixel' // // here can you change the cookie name
},
// defines the environments where the tracking should be available - default is ["production"]
environments: ['production', 'development']
}
},