Skip to content

tracker 0.0.3

Install from the command line:
Learn more about npm packages
$ npm install @oddcamp/tracker@0.0.3
Install via package.json:
"@oddcamp/tracker": "0.0.3"

About this version

Odd Camp tracking helpers library

A collection of tracking helper functions for snappier analytics.

Supported tracker services

  • Plausible

Usage

  1. Install
$ yarn add @oddcamp/tracker
  1. Enjoy
import { enableAutoEventTracking } from "@oddcamp/tracker"

enableAutoEventTracking()

HTML

  <a href="/" data-track-event='{"name": "Click", "props": {"trigger": "anchor"}}'>
    Link
  </a>

ERB

  <%= link_to 'Link', root_path, data: {track_event: {name: 'Click', props: {trigger: 'anchor'}}} %>

JSX

  <a href="/" data-track-event={JSON.stringify({name: 'Click', props: {trigger: 'anchor'}})}>
    Link
  </a>

Development

  1. Create .env and add tracker variables you prefer to test:
    • PLAUSIBLE_DOMAIN
  2. $ yarn install
  3. $ yarn dev
  4. localhost:1234

API

enableAutoEventTracking

Enabled automatic event tracking.

Defaults:

enableAutoEventTracking({
  attributeName = `track-event`,
  sourceNode = document,
  targets = [`a`, `button`],
  trackers = [`plausible`],
  debug = false,
})

Returns: function which disables automatic event tracking if executed, e.g.:

const disableAutoEventTracking = enableAutoEventTracking()
// ...
disableAutoEventTracking()

trackEvent

Tracks an event.

Defaults:

trackEvent({ 
  data, 
  trackers = [`plausible`],
  debug = false 
})

Example:

trackEvent({
  data: {
    name: `Event name`,
    props: { name: `value` },
  },
})

Details


Assets

  • tracker-0.0.3.tgz

Download activity

  • Total downloads 0
  • Last 30 days 0
  • Last week 0
  • Today 0

Recent versions

View all