Send Ninetailed Experience views as Twilio Segment `track` events.
Segment is a powerful customer data orchestration tool. This plugin allows you to send experience views to a Segment as track events via a connected Analytics.js source.
Looking to send data from Segment to Ninetailed instead? Check out the Customer Data documentation.
import { Ninetailed } from'@ninetailed/experience.js';import { NinetailedSegmentPlugin } from'@ninetailed/experience.js-plugin-segment'exportconstninetailed=newNinetailed( { clientId:// Your client ID environment: // Your Ninetailed environment }, { plugins: [newNinetailedSegmentPlugin() ],// Specify an amount of time (ms) that a component must be present in the viewport to register a component view componentViewTrackingThreshold:2000, });
Timing Configuration
The Insights Plugin logs that a component has been seen only after the component has remained within the user's viewport for a specified amount of time (in milliseconds), determined by the value of the componentViewTrackingThreshold property on the Ninetailed instance (see code samples above). If the option is unspecified, the value defaults to 2000.
Default Data Layer Properties
Events sent from this plugin are named nt_experience. They are sent with five default parameters:
Custom Event Properties
You can also define your own variables to push to Segment by passing in a configuration object when instantiating the plugin. To do so, define a config object with a template property whose value is an object consisting of key-value pairs, where the key is the name of the property you want to add to the Segment track event and the value is a string of the desired variable value surrounded by double curly braces ({{ }}).
Available Properties
Example Custom Use
This example shows passing the human-readable name of an audience to a custom event property titled ninetailed_audience_name. The default event properties are also pushed.
import { Ninetailed } from'@ninetailed/experience.js';import { NinetailedSegmentPlugin } from'@ninetailed/experience.js-plugin-segment'exportconstninetailed=newNinetailed( { clientId:// Your client ID environment: // Your Ninetailed environment }, { plugins: [newNinetailedSegmentPlugin({ template: { ninetailed_audience_name:'{{ audience.name }}', }, }) ],// Specify an amount of time (ms) that a component must be present in the viewport to register a component view componentViewTrackingThreshold:2000, });