Sending Events
This guide describes how to use Ninetailed Analytics and Events in React.

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 { track, page, identify } = useNinetailed();
return (<button
onClick={() => { track('built new Rick'); }}
build new Rick

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 = () => Promise<void>;

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>;

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.
Copy link
On this page
Tag Manager