Sending Events

Tracking user interaction to gather information which can be used to define Audiences.
To personalize content, Ninetailed requires context in the form of customer data. This context will be populated for each user over time. One way to create more context is to send events via the Experience SDK.
To make this process as easy as possible, Ninetailed provides the page, track and identify methods which can be used via the useAnalytics hook or via the window object of the browser, for example, in a Tag Manager.


There are three main events that the SDK provides.


Page views should be sent on every page change (for React only, as other SDKs are taking care of this automatically). Our SDK populates all data needed as, referrer, url, user-agent and other properties to be consumed by the API.
type Page = (properties?: Object) => Promise<void>;
While most of the time you will call this page method with no arguments, you may optionally specify any properties you would like to associate with the page view event. This can be useful for creating Audiences. For example, if the category to which viewed blog posts belong is not contained within the URL of the blog posts, but you'd like to create an Audience of visitors who have viewed blog posts of a certain category a certain number of times, you can pass the category along as a custom property:
page({'category': 'YOUR_BLOG_CATEGORY'})


Track events are used to log specific named actions a user takes, like signup or registered_for_newsletter.
type Track = (event: string, properties?: Object) => Promise<void>;
Track events may also accept a properties argument detailing additional information. For example, you might include the SKU and quantity of items on an add_to_cart event.
track('add_to_cart', {sku: 'Q-123', quantity: 1})


Identify events have two purposes:
  1. 1.
    To add key:value pairs, called traits, to a profile. Traits can be any attribute of interest about a customer.
  2. 2.
    To add an alias profile such that it can be referenced by that alias in the future. An ID stored within an analytics system, customer data platform, or e-commerce platform make ideal aliases.
type Identify = (uid: string, traits?: Traits) => Promise<void>;

`useNinetailed` Hook

The useNinetailed hook provides the tracking functions functions page, track, and identify for React- and React framework-based implemetations.
import React from 'react';
// or '@ninetailed/experience.js-next' or `'@ninetailed/experience.js-gatsby'
import { useNinetailed } from '@ninetailed/experience.js-react';
const CallToAction = () => {
const { page, track, identify } = useNinetailed();
return (<button
onClick={() => { track('add_to_cart'); }}
When using the React SDK, we highly recommend triggering page views by an automated tracker, depending on your router. Our Next.js and Gatsby SDKs send page view events automatically. Therefore, make sure to avoid sending any further page view events for these SDKs