Package Exports
- @glorious/analytics
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@glorious/analytics) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Glorious Analytics
Privacy-first analytics.
Installation
npm install @glorious/analytics --save
Usage
Glorious Analytics is based on Plausible, a simple and privacy-friendly alternative to Google Analytics.
import GAnalytics from '@glorious/analytics';
const analytics = new GAnalytics();
analytics.init('glorious.codes');
analytics.trackPageview();
To avoid been tracked by any site using Glorious Analytics, set analytics
search param as disabled
. Your preference will be set in a cookie and the following visits won't be tracked even without declaring the analytics search param on url.
https://glorious.codes?analytics=disabled
API
init
/*
** @token: String [required]
** @options: Object [optional]
*/
// Domain registered on Plausible
const token = 'glorious.codes';
// Local development is not tracked by default, but you can make it work by
// setting trackLocalhost option as true on initializaton.
const options = { trackLocalhost: true };
const analytics = new GAnalytics();
analytics.init(token, options);
trackPageview
analytics.trackPageview();
Contributing
Install Node. Download the "Recommend for Most Users" version.
Clone the repo:
git clone git@github.com:glorious-codes/glorious-analytics.git
- Go to the project directory:
cd glorious-analytics
- Install the project dependencies:
npm install
- Build the project:
npm run build
Tests
Ensure that all code that you have added is covered with unit tests:
npm run test -- --coverage