Ninetailed
Search…
⌃K

Merge Tags

This page describes merge tags and how to use them in Contentful.

Introduction

Merge tags or personalization tags allow you to insert data and dynamic visitor content. For example the visitor's city.
Default location merge tags are available on selected accounts. Contact us to enable location merge tags.

How to Add a Merge Tag

To add a merge tag to a rich text field click Embed inline entry and select a Nintetailed Merge Tag.

Location Merge Tags

  • City of the visitors, e.g. "Berlin"
  • Country of the visitors, e.g. "Germany"
  • Postal code of the visitor, e.g. "10214"
  • Region of the visitor, if known, the ISO 3166-2 name for the first level region, e.g. "Berlin".
You can localize the city and country merge tags adding the locale code in the <Personalization locale ="YOUR_ISO_LOCALE"/>

User Traits Merge Tags

You can set unlimited user traits to merge tags with the identify analytics call, e.g. first name, role, or company.

Add Merge Tags

To use your user traits merge tags in Contentful add a new entry for every trait, e.g. first name.
  1. 1.
    Create a new merge tag.
  2. 2.
    Add the ID of your user trait. Use the prefix traits_ and your trait name, e.g. traits_firstname.
  3. 3.
    Publish the entry.

Rich Text Rendering with MergeTags

Contentful provides libraries for all major JS frameworks to render rich text easily. Here is an example on how to render Ninetailed MergeTags through the Contentful react rich text renderer.
import { documentToReactComponents } from '@contentful/rich-text-react-renderer';
import { MergeTag } from '@ninetailed/experience.js-next';
const RichTextSection = () => {
const RTComponent = documentToReactComponents(rtd, {
renderNode: {
[INLINES.EMBEDDED_ENTRY]: (node) => {
// ... you other embedded entries
if (node.data.target.sys.contentType.sys.id === 'nt_mergetag' && node.data.target.fields.nt_mergetag_id) {
return <MergeTag id={node.data.target.fields.nt_mergetag_id} />;
}
return null;
}
}
});
return <RTComponent />
}