Setting up Segmentation

By sending Candu data attributes about your users you can personalize their experience within your application.

Lauren Cumming avatar
Written by Lauren Cumming
Updated over a week ago

With Candu, you can create and publish different content for different user segments. To create user segments, you will need to send the necessary data attributes to Candu, either directly or via a third-party provider.

Required: please note you will need the ability to identify users with a unique ID such as an ID you have assigned them or email address, otherwise they will be tracked anonymously.

Sending User Data Directly

A common option to get your user data into Candu is sending it directly via the installation script.

You will need to pass your UserId (unique ID or email address) through to Candu so we can identify your users.

To do so, you must specify a UserId parameter in Candu's installation script.

For example:

<script>
(function(d, params){
var script = d.createElement('script');
script.setAttribute('src', 'https://cdn.candu.ai/sdk/latest/candu.umd.js?token=' + params.clientToken);
script.onload = function () { Candu.init(params); }
d.head.appendChild(script);
})(document, {
clientToken: 'YOUR_CLIENT_TOKEN',
userId: 'YOUR_USER_ID',
});

You can then pass through data:

  • Any user traits about your users such as email, role type, plan type and company name

  • Any user events such as completion of key product actions like 'Invited team member'

You will be able to use this data for segmentation and personalization purposes.

User Traits Example

<script>
(function(d, params){
var script = d.createElement('script');
script.setAttribute('src', 'https://cdn.candu.ai/sdk/latest/candu.umd.js?token=' + params.clientToken);
script.onload = function () { Candu.init(params); }
d.head.appendChild(script);
})(document, {
clientToken: 'YOUR_CLIENT_TOKEN',
userId: 'YOUR_USER_ID',

// ADD ANY TRAITS IN THE OBJECT BELOW
traits: { email: '[email protected]' },
});
</script>

To see all the options available when initializing Candu, please refer to the Javascript API.

ℹ️ Reserved traits Candu has standardized:

Trait

Type

Description

email

String

Email address of a user

Please make sure to the email through with a lowercase 'e'.

User Events Example

You can pass user events by calling the window.Candu.getEventing() method in the Candu singleton. For full details, please refer to the API page.

Third-party Integrations

Segment.io Integration

This integration sends user event data via the Segment.io function to Candu, where it can be used to personalize content.

If you are using Segment.io to send Candu user event data, you will need to send it as identify calls with user traits. For example:

If you are using Segment.io to send Candu user event data, you will need to send it as identify calls with user traits.
analytics.identify("some_user_id", { name: "Some Person", email: "[email protected]", logins: 5});

For more information on installing Segment integration, please refer to the Segment section in the Candu Destination documentation.

ℹ️ In order to create user segments, an identify event with traits is required. Tracking events with properties will not be sufficient.

Did this answer your question?