Segmentation and custom data

Segmentation is a powerful tool for displaying different content for different users. Product Fruits can use your application's data to target the right cohorts.

Custom data

When you integrate our JavaScript snippet, you can also provide customized user data. This will allow you to use them for segmentation rules or as placeholders in your content.

This is how you can provide custom data:

const productFruitsUserData = {
   username: '', // the unique user ID, this property is required
   email: '', //
   firstname: '',
   lastname: '',
   signUpAt: '',
   role: '',
   props: {
      customProperty1: '',
      customProperty2: 123,
      customArray: ['a', 'b']

As you can see, apart from the predefined properties like username, first name, etc., you can choose to include the props field and insert any custom data you need.

React, NextJS

The user information has to be provided as a prop to our React component.

<ProductFruits workspaceCode='...' language='en' user={productFruitsUserData} />

Standard JavaScript snippet

Assign the variable to the window.productFruitsUser variable before the JavaScript snippet is executed. Do not change this variable after the Product Fruits snippet is initialized. If you want to change the user data later, use the productFruits.identifyUser({...}) method.