How set up a Gatsby Cookie consent banner with gatsby-plugin-gdpr-cookies

后端 未结 3 1051
日久生厌
日久生厌 2021-01-02 09:06

My website gathers information for Google Analytics, so I need to include a Cookie consent banner for the users to opt in/out of.

I saw the plugin gatsby-plug

3条回答
  •  爱一瞬间的悲伤
    2021-01-02 09:54

    Attention, I had an issue with tracking via Google Analytics. After a lot of research I found the solution in the reactGaOptions which is used under the hood by gatsby-plugin-google-analytics-gdpr. Use the sampleRate option to enable 100% tracking so that also mobilephones will send the requests to Google. In normal mode it is set to 1% so in low bandwith you will loose a lot of user information.

    reactGaOptions: {
      debug: false,
      gaOptions: {
        sampleRate: 100,
        siteSpeedSampleRate: 100
      }
    }
    

提交回复
热议问题