Skip to main content

Custom Segments

Zuora

Custom Segments

The Custom Segments extension allows the posting of arbitrary segments to an endpoint exposed on the Zephr CDN. This extension can be configured with an arbitrary number of segment groups and their corresponding segments to allow their usage in Zephr rules.

Prerequisites

The process of fetching segments for a given user from an external system is out of scope for this extension, so it is expected that some other process will fetch these before posting them to Zephr.

Behaviour

The extension performs 2 main functions:

  1. A listener to which segments can be posted (on a per-user basis) will be exposed at the following path: “/plugins/public/custom-segments/update-custom-segments”
  2. According to the extension configuration, one or more decision points will be added to the Zephr Rules builder to allow use of custom segments in rules.

Configuration

To configure the extension, navigate to Settings > Extensions > Custom Segments in the Zephr Admin Console. The extension requires a JSON array to declare the segment groups and segments that you wish to use. The configuration must include one or more segment groups.

Example configuration:

[
  {
    "name": "Segment Group 1",
    "id": "segmentGroup1",
    "segments": [
      {
        "name": "Segment 1",
        "id": "seg1"
      },
      {
        "name": "Segment 2",
        "id": "seg2"
      },
      {
        "name": "Segment 3",
        "id": "seg3"
      }
    ]
  },
  {
    "name": "Segment Group 2",
    "id": "segmentGroup2",
    "segments": [
      {
        "name": "Segment A",
        "id": "segA"
      },
      {
        "name": "Segment B",
        "id": "segB"
      },
      {
        "name": "Segment C",
        "id": "segC"
      }
    ]
  }
]

We have used segment groups named “Segment Group 1” and “Segment Group 2” simply as neutral examples: it is recommended that you use segment group names (and IDs) that correspond to the system(s) from which you are gathering segments.

Activation

Once you’ve input the relevant details, confirm for which of your Sites the extension should be active. To do this, use the toggles for each site under the Activate Plugin section, or choose Select All Sites.

Usage

Posting segments for a user

To add segment membership data for a given user to Zephr, segments must be posted to the listener at the following path: “/plugins/public/custom-segments/update-custom-segments”.

The request must include a way of identifying the user (for example a “blaize_session” or “blaize_jwt” cookie).

Example request:

POST /plugins/public/custom-segments/update-custom-segments HTTP/1.1
Host: alex4-zephr-news.cdn.zephr.com
Content-Type: application/json
Cookie: blaize_session=39230ba6-bd18-42a0-8465-b712250637b9
Content-Length: 122
{
  "customSegments": {
    "segmentGroup1": ["seg1"],
    "segmentGroup2": ["segB", "segC"]
  }
}

The body of the request must be an object with a single customSegments key. The value will be an object with keys for each segment group for which you wish to post segments. Segments for a given segment group must take the form of an array where members are either strings or numbers (or both). The example above uses segmentGroup1 and segmentGroup2 as per our configuration example.

Using segments in rules

Once the extension is active, you will see one or more additional Custom Segment nodes available for use on the Zephr rules canvas:

custom_seg_rule1_mar24-768x114.png

When you drag a Custom Segment node to the canvas, a modal will open that will allow you to select a segment that belongs to that segment group:

custom_seg_rule3_mar24-768x248.png

Once configured, the Custom Segment node can be used in your rule, e.g.:

custom_seg_rule2_mar24-768x406.png

Notes

Pay attention to the following when using this extension:

  • This extension does not have any functionality to fetch segments from external systems, nor is it able to fetch segment metadata in order to create the additional Zephr Rules canvas nodes.
  • The process of posting segments to the listener and the process of a given user browsing web pages are decoupled from each other: this means that if segments are posted from a script that is running in the user’s browser, whilst segment membership data will likely be available for the subsequent page view, this cannot be guaranteed (depending on how rapidly the user browses).
  • Each Custom Segment node will only test against a single segment ID for a given user.