【发布时间】:2021-03-18 06:56:44
【问题描述】:
所以我在gatsby-plugin-gdpr-cookies 插件之后设置了一个基本的cookie 横幅,我使用了react-cookie-consent,但它只显示了一个带有接受按钮的简单we use cookies on our website。
-
如何在我的 cookieconsent 组件中同时传递
google analytics和google tag manager?文档仅显示一个 cookieName,我不知道如何添加更多内容,而不仅仅是 google 分析? -
另外,我如何检查它是否真的禁用了 cookie 跟踪?
我将插件添加到我的gatsby-config.js
{
resolve: `gatsby-plugin-gdpr-cookies`,
options: {
googleAnalytics: {
trackingId: 'YOUR_GOOGLE_ANALYTICS_TRACKING_ID', // leave empty if you want to disable the tracker
cookieName: 'gatsby-gdpr-google-analytics', // default
anonymize: true, // default
allowAdFeatures: false // default
},
googleTagManager: {
trackingId: 'YOUR_GOOGLE_TAG_MANAGER_TRACKING_ID', // leave empty if you want to disable the tracker
cookieName: 'gatsby-gdpr-google-tagmanager', // default
dataLayerName: 'dataLayer', // default
},
facebookPixel: {
pixelId: 'YOUR_FACEBOOK_PIXEL_ID', // leave empty if you want to disable the tracker
cookieName: 'gatsby-gdpr-facebook-pixel', // default
},
// defines the environments where the tracking should be available - default is ["production"]
environments: ['production', 'development']
},
},
然后我将 Cookie 横幅添加到我的 layout.js
<CookieConsent
location="bottom"
buttonText="Accept"
declineButtonText="Decline"
cookieName="gatsby-gdpr-google-analytics"
>
This website uses cookies to enhance the user experience.
</CookieConsent>
另外,cookie 只跟踪 gatsby-gdpr-google-analytics,但我也需要它来跟踪 gatsby-gdpr-google-tagmanager
【问题讨论】:
标签: javascript reactjs cookies graphql gatsby