Noncollinear Perpendicular Microcrystalline
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@jike-fe/jk-analytics

0.1.10 • Public • Published

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

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

Config: Set User ID

Set the userId on the tracker:

JKA.setUser(userId, userData)

Config: Set Current Page

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

Track: Page View in SPA

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:

JKA.event({
  page: 'Download Page',
  action: 'Download Jike app',
  label: 'Superhero button'
})

Or, easily add data-jka="{}" to a DOM element as:

<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

License

MIT

Keywords

none

Install

npm i @jike-fe/jk-analytics

DownloadsWeekly Downloads

9

Version

0.1.10

License

MIT

Unpacked Size

39.7 kB

Total Files

15

Last publish

Collaborators

  • avatar
  • avatar
  • avatar