Collecting data with Trackers and Webhooks

  1. Home
  2. Docs
  3. Collecting data with Trackers and Webhooks
  4. Trackers – collecting data from your own applications
  5. JavaScript Trackers (Web and Node.js)
  6. Browser Tracker
  7. Browser Tracker v3 Reference
  8. Plugins
  9. Adding plugins to your tracker

Adding plugins to your tracker

The Snowplow JavaScript Trackers v3 allow extension via plugins. There a number of official Snowplow plugins, but we also encourage building your own. You can either include them directly in your codebase or tag management tool, or you could publish them to npm as public packages that the whole community can use.

There are two ways to add plugins:

  • During tracker intialization
  • Dynamically after tracker intialization

Tracker Initialization

To add a plugin at tracker intialisation, you include the plugin in the Plugins array:

import { newTracker } from '@snowplow/browser-tracker'; import { PerformanceTimingPlugin } from '@snowplow/browser-plugin-performance-timing'; newTracker('sp', '{{collector_url_here}}', { appId: 'my-app-id', contexts: { webPage: true // default, can be omitted }, plugins: [ PerformanceTimingPlugin() ] });
Code language: JavaScript (javascript)

After Tracker Initialization

To add a plugin after tracker intialisation, you can call addPlugin and pass the plugin in:

import { newTracker, addPlugin } from '@snowplow/browser-tracker'; import { PerformanceTimingPlugin } from '@snowplow/browser-plugin-performance-timing'; newTracker('sp', '{{collector_url_here}}', { appId: 'my-app-id', contexts: { webPage: true // default, can be omitted } }); ... addPlugin({ plugin: PerformanceTimingPlugin() });
Code language: JavaScript (javascript)

If you’d like to learn more about Snowplow Insights you can book a demo with our team, or if you’d prefer, you can try Snowplow technology for yourself quickly and easily.