==========
DEPRECATED
==========
This project is deprecated. Please directly embed the GA code or use a wrapper function (like in the BecklynRadBundle (https://github.com/Becklyn/BecklynRadBundle)) for the embedding.
A google analytics wrapper which helps to be compatible with German data privacy laws.
It only supports universal tracking.
Download the JavaScript file in the dist/
directory or install it using bower (or any similar package manager).
At first you need to initialize the API:
Becklyn.Google_Analytics.init(code [, initCallback]);
Parameters:
code
(required): the Google Analytics tracking code (in the form of"UA-XXXXXXX-X"
)initCallback
(optional): a function, which is called when initializing the google analytics function (receivesga
as only parameter)
The API is very simple:
/**
* Toggles the active state.
* It sets the API inactive, when it was active and vice versa.
*
* @return {Boolean} the new active state
*/
Becklyn.Google_Analytics.toggleActive();
/**
* Returns, whether the user has activated the tracking
*
* @returns {Boolean}
*/
Becklyn.Google_Analytics.isActive();
The library automatically sets a cookie when disabling the tracking, which is valid "forever" (until 2100). It will automatically disable the tracking when a user is reentering the page (except they deleted the cookies).