Skip to content

analytics 0.0.5

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

About this version

Odd Camp analytics helpers library

A collection of analytics helper functions.

Supported analytics services

  • Plausible

Usage

  1. Install
$ yarn add @oddcamp/analytics
  1. Enjoy
import { enableAutoEventAnalytics } from "@oddcamp/analytics"

enableAutoEventAnalytics()

HTML

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

ERB

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

JSX

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

Development

  1. Create .env and set variables of analytics services you prefer to test:
    • PLAUSIBLE_DOMAIN
  2. $ yarn install
  3. $ yarn dev
  4. localhost:1234

API

enableAutoEventAnalytics

Enabled automatic event analytics.

Defaults:

enableAutoEventAnalytics({
  attributeName = `event-analytics`,
  sourceNode = document,
  targets = [`a`, `button`],
  services = [`plausible`],
  debug = false,
})

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

const disableAutoEventAnalytics = enableAutoEventAnalytics()
// ...
disableAutoEventAnalytics()

analyticizeEvent

Analyticizes an event.

Defaults:

analyticizeEvent({ 
  data, 
  services = [`plausible`],
  debug = false 
})

Example:

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

Details


Assets

  • analytics-0.0.5.tgz

Download activity

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

Recent versions

View all