Ninetailed
Search…
⌃K

Quick Start for Developers (React)

This quick reference guide describes the steps you need to follow to integrate Ninetailed in your website.
In this quick guide you will learn how to integrate Ninetailed in a website using Contentful as headless CMS and React for the frontend in five steps:
  1. 1.
    Install Contentful App
  2. 2.
    Create a personalized variant
  3. 3.
    Install React SDK
  4. 4.
    Get visitor profile
  5. 5.
    Personalize components

Step 1: Install Contentful App

Install our Contentful App from the official marketplace.
  1. 1.
    Select the space and environment you want to install the app.
  2. 2.
    Authorize the app access.
  3. 3.
    Link your Contentful account to Ninetailed.
  4. 4.
    Create an organization in Ninetailed.
  5. 5.
    Set up the content types for dynamic content personalization.
  6. 6.
    Confirm your settings and install the app. 🙃
Find more information about the install process in the Contentful section.

Step 2: Create a Personalized Variant

A variant is a relevant content for a specific audience. To create a variant in Contentful:
  1. 1.
    Edit or create an entry of any content type which was set up in the install process.
  2. 2.
    Create a new variant for the entry and update the content.
  3. 3.
    Create a new audience and publish it.
  4. 4.
    Publish the variant and the entry and you're done. 🙌
Find more information about how to define a new audience in the Audience Builder section.

Step 3: Install React SDK

To show the variants in the frontend you need to install Ninetailed React SDK.

1. Install

Install @ninetailed/experience.js-react module via npm or yarn.
yarn add @ninetailed/experience.js-react

2. How to use

This is what the configuration of @ninetailed/experience.js-react looks like:
import React from 'react';
<NinetailedProvider
// ...
plugins={[
new NinetailedGoogleAnalyticsPlugin({
actionTemplate: 'User has seen personalized component:{{Audience.id}}',
labelTemplate:'{{ baselineOrVariant }}: {{ component.__typename }} - {{ component.id }}',
})
]}
>
//... Your Application Components
</NinetailedProvider>
Your API Key can be found in the CMS or Ninetailed dashboard configuration.

Step 4: Get visitor profile

The next step is to fire a page view to get the profile of the visitor.
This is what a page view looks like:
import React, { useEffect } from 'react';
import { useAnalytics } from '@ninetailed/experience.js-react';
export const Page = () => {
const { page } = useAnalytics();
useEffect(() => {
page();
}, [page]);
// ... your Page component
};

Step 5: Personalize components

To show the variants in the frontend you need to wrap the components to be personalized.
import React, { useState, useEffect } from 'react';
import { Experience, useAnalytics } from '@ninetailed/experience.js-react';
import Headline from '../Headline.dynamic';
export const Page = () => {
// ...page view effect from Step 4
// fetch the content
const [page, setPage] = useState(null);
useEffect(() => {
// Fetch your content from Contentful as before, just make sure the variants will get fetched.
const { page } = getPageFromContentful();
setPage(page);
}, [setPage]);
return <>
<Experience component={Headline} experiences={page.headline.nt_experience} id={page.headline.sys.id} {...page.headline} />
{/* ...the rest of your page */}
</>
};