https://github.com/vesparny/fair-analytics-client-api
The Fair Analytics client API
https://github.com/vesparny/fair-analytics-client-api
analystics analytics fair ga google
Last synced: about 1 year ago
JSON representation
The Fair Analytics client API
- Host: GitHub
- URL: https://github.com/vesparny/fair-analytics-client-api
- Owner: vesparny
- License: mit
- Created: 2017-05-05T07:23:08.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-04T19:41:36.000Z (over 7 years ago)
- Last Synced: 2025-03-29T06:51:32.694Z (about 1 year ago)
- Topics: analystics, analytics, fair, ga, google
- Language: JavaScript
- Size: 57.6 KB
- Stars: 20
- Watchers: 4
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Fair Analytics client JavaScript API
> The quickest way to integrate [Fair Analytics](https://github.com/vesparny/fair-analytics) in your app
[](https://travis-ci.org/vesparny/fair-analytics-client-api)
[](https://codecov.io/github/vesparny/fair-analytics-client-api)
[](https://david-dm.org/vesparny/fair-analytics-client-api)
[](https://www.npmjs.com/package/fair-analytics-client-api)
[](https://npm-stat.com/charts.html?package=fair-analytics-client-api&from=2017-04-01)
[](http://standardjs.com/)
[](https://github.com/vesparny/fair-analytics-client-api/blob/master/LICENSE)
[](https://unpkg.com/fair-analytics-client-api/dist/)
## Install
This project uses [node](http://nodejs.org) and [npm](https://npmjs.com). Go check them out if you don't have them locally installed.
```sh
$ npm i fair-analytics-client-api
```
Then with a module bundler like [rollup](http://rollupjs.org/) or [webpack](https://webpack.js.org/), use as you would anything else:
```javascript
// using ES6 modules
import fairAnalytics from 'fair-analytics-client-api'
// using CommonJS modules
var fairAnalytics = require('fair-analytics-client-api')
```
The [UMD](https://github.com/umdjs/umd) build is also available on [unpkg](https://unpkg.com):
```html
```
You can find the library on `window.fairAnalytics`.
## Usage
```js
import fairAnalytics from 'fair-analytics-client-api'
// create a fa instance
const fa = fairAnalytics({
url: 'https://fa.yoursite.com' // the URL of your hosted Fair Analytics instance
})
// track events
fa.send({
event: 'pageView', // event is mandatory and can be anything
pathname: window.location.pathname
})
.then(res => {
if (res.ok) {
console.log('success')
}
})
.catch(err => {
console.error(err.message)
})
```
## Tests
```sh
$ npm test
```
## Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
Every release, along with the migration instructions, is documented in the [CHANGELOG.md](https://github.com/vesparny/fair-analytics-client-api/blob/master/CHANGELOG.md) file.
## License
MIT