Sending Events

This guide describes how to use Ninetailed Analytics and Events in JavaScript-based SDKs..


To personalize the content we need to know about the visitor currently viewing the page. This data is managed by our customer data platform. Anyhow you need to send events about the user to our API so it can aggregate a profile over time.
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.
We recommend triggering Pageviews by an automated tracker depending on your router. For frameworks like Next.js an <AutoTracker /> is prebuilt.


The useNinetailed hook provides the event tracking functions inside your React components. This is very handy if you want to send events from your code.
import React from 'react';
import { useNinetailed } from '@ninetailed/experience.js-react';
const CallToAction = () => {
const { page, track, identify } = useNinetailed();
return (<button
onClick={() => { track('built new Rick'); }}
build new Rick


Page view

Page views should be sent on every page change. 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 describe special actions the user did, like signup or registered_for_newsletter.
type Track = (event: string) => Promise<void>;


By identifying a user you add a custom id to the profile, like a Hubspot id or an id from your internal database. Even more important, you can set traits about this customer, like the firstname, age or anything you want to personalize the content even more.
type Identify = (uid: string, traits: Traits) => Promise<void>;

Tag Manager

The Analytics SDK also adds the page(), track() and identify() functions to the window object. That way you can also access them from a Tag Manager. We recommend sending pageviews directly from the code as soon as the SDK is initialized so the personalizations are not delayed.