analytics-plugin-hubspot

0.1.2 • Public • Published

HubSpot plugin for analytics

Note: This package has moved to @analytics/hubspot

Integration with HubSpot for analytics

View the docs

Usage

Install analytics and @analytics/hubspot packages

npm install analytics @analytics/hubspot

Import and initialize in project

import Analytics from 'analytics'
import hubSpotPlugin from '@analytics/hubspot'
 
const analytics = Analytics({
  app: 'awesome-app',
  plugins: [
    hubSpotPlugin({
      portalId: '234576'
    })
  ]
})
 
/* Track page views */
analytics.page()
 
/* Track custom events */
analytics.track('buttonClicked')
 
/* Identify visitors */
analytics.identify('user-xzy-123', {
  email: 'bill@murray.com',
  accountLevel: 'pro'
})

Using identify

Important: HubSpot requires an email field for making identify calls.

If your identify call does not contain email HubSpot will not be notified of the new user.

When sending properties with identify calls, all camelCase traits are automatically converted to snake_case. There is one exception to this for firstName & lastName which are sent as firstname & lastname.

Example:

analytics.identify('user-xzy-123', {
  email: 'bill@murray.com',
  accountLevel: 'pro' // trait will be `account_level`
})

Configuration

Plugin Options

Arguments

  • pluginConfig object - Plugin settings
  • pluginConfig.portalId string - The HubSpot Portal (or Hub) Id of your HubSpot account

Example

hubSpotPlugin({
  portalId: '234576'
})

Package Sidebar

Install

npm i analytics-plugin-hubspot

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

29.6 kB

Total Files

9

Last publish

Collaborators

  • davidwells