# @jike-fe/jk-analytics

> I am a log maker, so I write logs JIKE by JIKE.

Latest version **0.1.10** (published 2018-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jike-fe/jk-analytics
pnpm add @jike-fe/jk-analytics
yarn add @jike-fe/jk-analytics
bun add @jike-fe/jk-analytics
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.10 |
| Published | 2018-03-30 |
| First published | 2018-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 38.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ryanwangtian, sunskyxh, zilin |

## Links

- npm: https://www.npmjs.com/package/@jike-fe/jk-analytics
- Repository: https://github.com/ruguoapp/JK-Analytics
- Homepage: https://github.com/ruguoapp/JK-Analytics#readme
- Issues: https://github.com/ruguoapp/JK-Analytics/issues
- npm.io page: https://npm.io/package/@jike-fe/jk-analytics

## Recent versions

- 0.1.10 (latest) — 2018-03-30
- 0.1.9 — 2018-03-15
- 0.1.8 — 2018-03-13
- 0.1.7 — 2018-03-13
- 0.1.6 — 2018-01-08

## README

# JK-Analytics

"I am a log maker, so I write logs JIKE by JIKE."

## Installation
```
$ npm i jk-analytics
```

## Usage

#### Config: Set Providers via DOM

```html
<script id="jka-providers"
  data-google="UA-3318xxxx-1"
  data-sensors="USER-4e7020cb"
></script>
```

#### Config: Set User ID
Set the `userId` on the tracker:
```javascript
JKA.setUser(userId, userData)
```

#### Config: Set Current Page

```javascript
// Set the current page, default value of the 'page' field while invoking JKA.event(options)
JKA.setCurrentPage('Home Page')
```

#### Track: Page View in SPA
```javascript
JKA.pageview({
  title: 'My Overridden Page', // Required.
  page: '/my-overridden-page' // Required. This value should start with a slash (/) character.
})
```
#### Track: Event
Event Options Table (analogous to GA) :

| Name        | Required           | Description  |
| ------------- |:-------------:| -----|
| page      | yes | The name of the page/activity (e.g. `About Page`) |
| action        | yes |   The type of interaction (e.g. `View Sune's Portfolio`) |
| label         | no  |   Useful for extra infos (e.g. `Junior Frontend Developver`) |

You can call the event function to track an event:
```javascript
JKA.event({
  page: 'Download Page',
  action: 'Download Jike app',
  label: 'Superhero button'
})
```

Or, easily add `data-jka="{}"` to a DOM element as:
```html
<button data-jka="{
  page: 'Download Page',
  action: 'Download Jike app',
  label: 'Superhero button'
}">Download App</button>
```

#### Debugging
To automatically log `event options`, you can use the `debug` mode:
```
JKA.enableDebug()
```

## Supported Analytics
- [Google Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/)
- [Sensors Data](https://www.sensorsdata.cn/manual/js_sdk.html)

## License
[MIT](./LICENSE)

---
_Source: https://npm.io/package/@jike-fe/jk-analytics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
