luciomartinez / gtag-opt-in

Google Analytics Opt In

Home Page:https://www.npmjs.com/package/gtag-opt-in

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Google Analytics Opt In

Warning

I'm deprecating this package as it requires more time, than what I can give, to keep it up-to-date so that the dependencies remain secure. My recommendation would be to read the source code and implement it in your website instead, as it should be easy enough yet secure.

GTag Opt In is a browser library to opt-in in Google Analytics. Plus, it configures Analytics to anonymize IP. See why and when to use it by reading the wiki page.

Install

NPM

npm install gtag-opt-in

Yarn

yarn install gtag-opt-in

HTML

<script src="https://www.npmcdn.com/gtag-opt-in"></script>

It imports the library as the GTagOptIn global variable.

Use

ES6

import * as GTagOptIn from 'gtag-opt-in';

GTagOptIn.register('UA-XXXXXXXXX-Y');
GTagOptIn.optin();
GTagOptIn.optout();

HTML

<script>
  GTagOptIn.register('UA-XXXXXXXXX-Y');
  GTagOptIn.optin();
  GTagOptIn.optout();
</script>

Documentation

Further documentation can be found at the wiki page.

Future

The library destiny is to be replaced with official support once Google Analytics releases the Consent mode feature which is currently under beta.

License

Software licensed under MIT license. See the LICENSE file.

About

Google Analytics Opt In

https://www.npmjs.com/package/gtag-opt-in

License:MIT License


Languages

Language:JavaScript 100.0%