analytics 0.0.4
Install from the command line:
Learn more about npm packages
$ npm install @oddcamp/analytics@0.0.4
Install via package.json:
"@oddcamp/analytics": "0.0.4"
About this version
A collection of analytics helper functions.
- Plausible
- Install
$ yarn add @oddcamp/analytics
- 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>
- Create
.env
and set variables of analytics services you prefer to test:PLAUSIBLE_DOMAIN
$ yarn install
$ yarn dev
- localhost:1234
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()
Analyticizes an event.
Defaults:
analyticizeEvent({
data,
services = [`plausible`],
debug = false
})
Example:
analyticizeEvent({
data: {
name: `Event name`,
props: { name: `value` },
},
})