andrezimpel / gatsby-plugin-gdpr-cookies

Gatsby plugin to add Google Analytics (V4 is supported), Google Tag Manager, Facebook Pixel, TikTok Pixel and Hotjar in a GDPR form to your site.
Apache License 2.0
101 stars 70 forks source link

gaOptOut() is undefined #10

Closed thisizkp closed 4 years ago

thisizkp commented 4 years ago

I've added the package to the gatsby site and added the google analytics ID as mentioned in the docs. I'm also setting a cookie with a value true/false based on user action. I would like to give an option to the user so that he can opt-out from future tracking.

I found the following in the docs section. <a href="javascript:gaOptout();">Deactivate Google Analytics</a> which can be used for opting out. I've used this and it doesn't seem working as expected. It throws an error saying that gaOptOut is undefined, which means that global analytics isn't set properly.

I might have missed something. How can I test if ga is being set properly?

andrezimpel commented 4 years ago

@thisizkp Please check our the updated readme. Since this plugin uses ReactGA you can use the OutboundLink.

Does this help you?

thisizkp commented 4 years ago

@andrezimpel Thanks, closing the issue.