Get segment membership

The Segment Membership API returns a JSON object containing the segment Ids that a user belongs to.

Once you have built segments, you use the Segment Membership API to GET the segments that each and every site visitor belongs to. Segment membership is based on a range of conditions that you build into each segment. Conditions are the basic building blocks of a segment and are based on contextual and behavioral information. See Segments for more information about building segments.

The Segment Membership API gives you the power to target specific segments as part of your marketing strategy. Examples of segment based decisions include:

  • Personalized content
  • Segment specific offers
  • Specific site features

The Segment Membership API should be used where your users’s membership state is unknown. Common examples include CMS systems and Mobile SDKs.

Prerequisites

Qubit integration

Qubit’s technology must be integrated into your website before you can start segmenting visitors. See Getting Set Up

Data layer

A data layer is crucial to getting better insights into site visitors and providing better on-site and app experiences. Qubit's data layer is called QProtocol.

On a technical level, the data layer serves to relay privacy aware visitor data to Qubit's Data Store, which is our data repository for quantitative and qualitative visitor data collected from your website.

Segments

Before using the Segment Membership API, you must first create your segments. Each segment is built using conditions that determine whether a user should be added to or removed from a segment.

See Segments for more information.

Unique values

Before using the Segment Membership API, you will require the following unique values:

Name

Description

Additional Information

<tracking_id>

Qubit tracking Id for the property the request is made from

This will be provided by your CSM

<visitor_id>

Unique site visitor Id, generated by the smartserve script on the page and is set in the cookies qb_permanent and qbTracker

You can extract this from the qb_permanent cookie using the regex /(^:+)/

If the qb_permanent cookie is missing, as is the case for first-time visitors, then you can omit this Id. Instead, the response will return the unique Id of each segment created in our platform.

Example flow

  1. The CMS receives a request for page load
  2. A GET request is made to the Segment membership API containing the Id of the user you want to find membership information for
  3. The API returns a JSON object that contains all the segment Ids the user is a member of

Technical details

Endpoint: https://segment-membership.qubit.com/

Making a request

Called via a GET request:

GET https://segment-membership.qubit.com/p/<tracking_id>?visitorId=<visitor_id>&userId=<visitor_id>

Sample request

GET https://segment-membership.qubit.com/p/union_fashion?visitorId=1479831298837.301540

Sample successful response

{
  segments: [
    { id: 'SG-4286-c58738a5' },
    { id: 'SG-4286-e84558b2' },
    { id: 'SG-4286-f437f311' }
  ]
}

Sample unsuccessful response

{
  error: {
    message: 'Bad request'
  }
}
Last updated: December 2021
Did you find this article useful?