Analytics plugin Planhat
This adds support for Planhat for the Analytics package.
Installation
npm install analytics analytics-plugin-planhat --save
Usage
Browser (Vue, React, Angular)
import { Analytics } from "analytics"
import planhatPlugin from "analytics-plugin-planhat"
const analytics = Analytics({
app: "[your app name]",
plugins: [
planhatPlugin({
tenantUUID: "[your tenantUUID]",
}),
],
})
Node
CommonJS
const { Analytics } = require('analytics')
// or const Analytics = require('analytics').default
const planhatPlugin = require('analytics-plugin-planhat')
const analytics = Analytics({
app: "[your app name]",
plugins: [
planhatPlugin({
tenantUUID: "[your tenantUUID]",
}),
],
})
ES6 Modules
import { Analytics } from 'analytics'
import planhatPlugin from 'analytics-plugin-planhat'
const analytics = Analytics({
app: "[your app name]",
plugins: [
planhatPlugin({
tenantUUID: "[your tenantUUID]",
}),
],
})
Methods
analytics.identify
Identify an user for which activities will be tracked.
analytics.identify([userId], {
firstName: "[firstName]"",
lastName: "[lastName]"",
email: "[email]",
companyExternalId:"[companyId]"
})
Argument | Description |
---|---|
userId |
Id for the Planhat user. If you want to identify users by mail pass null
|
email |
Email of the user. Either userId or email is required to identify the user. Provide an email if the userId is null . |
firstName |
Firstname of the Planhat user |
lastName |
Lastname of the Planhat user |
companyExternalId |
ExternalId of a company in Planhat, the company must exist in Planhat. Is required for the auto-creation of users. |
analytics.track
Track an user activity for the identified user.
analytics.track([activity name], {
[extraAttribute]: [value],
...
})
Argument | Description |
---|---|
activity name |
Name of the tracked user activity |
extraAttribute |
Add additional information about the user activity |
If you only want to use this plugin:
analytics.track([activity name],
{
[extraAttribute]:[value]
},
{
plugins: {
all: false,
planhat: true
}
}
);
More
More information about the usage of the methods and additional options can be found at the original analytics package: