Real-time Customer Segments for Discovery Integration

This guide gives you a high-level integration overview for the Real-time Customer Segments feature.


Integration Prerequisites
The Discovery pixel and Engagement pixel should already be configured on your site. If this is not the case, please engage with the services team to implement them. Visit Technical Overview and Implementing via Google Tag Manager for Engagement pixel implementation.

Knowledge Prerequisites
We recommend that you review the following guides:

Concepts Overview

A segment is a way to group users based on one or more properties that define them. Each property is defined by a dimension (or, to keep it simple, a “segment name”) that has a value (so-called “segment value”).

A dimension(or segment name) is the identifier of the property that groups users. It can also be thought of as an attribute, based on which we slice the population into groups. For example, country, occupation, gender, and customer tier (membership-level). Every dimension has a priority.

For now, the dimension can only be a customer_tier.

Integration Setup

Following are the steps involved in integrating Real-time Customer Segments:

Engagement Side Integration

Finding the segment for a client

  1. In the UI where you manage Data & Assets, navigate to Tag Manager to create a new personalized tag

  2. For each segmentation, you will include its ID in jinja code e.g.

{{ segmentations['5be40a092d020500159aa97a'] }}
  1. The client-side code is then written to pick up the tag's value. This is passed into backend API calls as discussed below:
let thisSegment = "{# Style Preference #}{{ segmentations['5fb3d59578c44bfbe9e4161d'] }}";
if(thisSegment !="None"){localStorage.setItem('segmentation', thisSegment) }
document.cookie="PJEsegment=" + thisSegment;
console.log('current segment:' + localStorage.getItem('segmentation'))

Discovery Side Pixel Updates

You must include the new segmentation value in every pixel request. So, for example, the global page tracking pixel would become:

<script type="text/javascript">
  var br_data = br_data || {};
  br_data.acct_id = "<Bloomreach Provided Account ID>"; 
  br_data.ptype = "<Bloomreach Page Type>";
  br_data.title = "<title of current page>";
  br_data.domain_key = "<Bloomreach Domain Key>";
  br_data.view_id = "<Bloomreach View ID>";
  br_data.user_id = "<Bloomreach User ID>";
  br_data.tms = "<Tag Management system to exclude during transition>";
  br_data.customer_tier = localStorage.getItem('bre_brd_segmentation') 

  (function() {
  var brtrk = document.createElement('script');
  brtrk.type = 'text/javascript';
  brtrk.async = true;
  brtrk.src = "//{{BloomReach Account ID}}.js";
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(brtrk, s);

Where the line br_data.customer_tier = localStorage.getItem('bre_brd_segmentation') sets the ‘segmentation customer_tier’ to the current value returned from Real-time Customer Segments the last time its personalized pixel fired.

What´s next?

Learn how to make segmented API calls

Did this page help you?