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
A collection of tracking helper functions for snappier analytics.
- Plausible
- Install
$ yarn add @oddcamp/tracker
- 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>
- Create
.env
and add tracker variables you prefer to test:PLAUSIBLE_DOMAIN
$ yarn install
$ yarn dev
- localhost:1234
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()
Tracks an event.
Defaults:
trackEvent({
data,
trackers = [`plausible`],
debug = false
})
Example:
trackEvent({
data: {
name: `Event name`,
props: { name: `value` },
},
})