Customer Segmentation API Guide
Get started with the Customer Segmentation API by creating Segments and Shopper Profiles. This guide provides example requests and responses to get you started customizing targeted shopper experiences.
Customer Segments
Create customer segments to offer customers targeted promotions. See the Customer Segmentation overview to get the big picture on targeting customers with promotions. For more granular details, see the Targeting a segment with a promotion section of this article.
Creating segments
Create new segments by sending a request to the Create segments endpoint. Include an array of objects, where each object represents a segment and contains name
and description
properties.
Segment names appear in the Promotions Manager view of the store control panel. To reduce confusion, give your segments unique names.
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/segments
X-Auth Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
[
{
"name": "My Segment",
"description": "Segment description."
}
]
Shopper profiles
Create a shopper profile to assign registered customers to segments. You can identify which registered customer a shopper profile represents by the profile's customer_id
property; shopper profiles have a 1:1 relationship with registered customers.
Existing customers
You can create one shopper profile for each registered customer using the Create shopper profiles endpoint. Include an array of objects, where each object represents a shopper profile and contains the corresponding customer_id
.
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/shopper-profiles
X-Auth Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
[
{
"customer_id": 1
}
]
New customers
To create a shopper profile for a new customer, first use the Create customers endpoint to register the customer, then create a shopper profile using the new customer_id
.
Add shopper profiles to a segment
After you create segments and shopper profiles, you can associate multiple shopper profiles with a given segment using the Add shopper profiles to a segment endpoint. Include the segmentId
as a path parameter, and pass an array of shopper profile id
s.
POST https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/segments/{{segmentId}}/shopper-profiles
X-Auth Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
[
"497f6eca-6276-4993-bfeb-53cbbbba6f08", // shopper profile UUID
]
Updating and deleting segments
Use the following guide to update or delete segments.
Update segments
Update segment names and descriptions using the Update Segments endpoint. Include an array of objects that each contain the segmentId
; name
and description
are optional.
PUT https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/segments
X-Auth Token: {{ACCESS_TOKEN}}
Content-Type: application/json
Accept: application/json
[
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "My Segment",
"description": "New and improved segment description."
}
]
Remove shoppers from a given segment
You may want to change the segments to which a shopper's profile belongs based on the shopper's behavior on the storefront. To remove one or more specific shopper profiles, use the Remove shopper profiles from a segment endpoint. Include the segmentId
as a path parameter, and use the id:in
query parameter to pass the shopper profile id
(s) you want to remove. If you exclude id:in
, this request will empty the segment of all shopper profiles.
Removing a shopper profile from a segment does not delete the shopper profile itself. The shopper profile will remain associated with any other segments.
DELETE https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/segments/{{segmentId}}/shopper-profiles
X-Auth Token: {{ACCESS_TOKEN}}
Accept: application/json
Delete segments
To delete segments, use the Delete segments endpoint. Segments and shopper profiles have a many-to-many relationship. Thus, all the shopper profiles associated with a deleted segment will still exist, but be disassociated from the deleted segment. Include the id:in
query parameter to specify which segments you want to delete.
DELETE https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/segments
X-Auth-Token: {{ACCESS_TOKEN}}
Accept: application/json
Delete shopper profiles
To delete shopper profiles, use the Delete shopper profiles endpoint. Include the id:in
query parameter to specify which shopper profiles you want to delete.
DELETE https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/shopper-profiles
X-Auth-Token: {{ACCESS_TOKEN}}
Accept: application/json
Retrieving segment information
Once you've established relationships between segments and shopper profiles, you can extend the reach of the Customer Segmentation API to target customers.
Retrieve shopper profiles for a segment
To keep your segments in sync with external apps, use the Get all shopper profiles in a segment endpoint. This request returns a list of all shopper profiles belonging to a specific segment.
GET https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/segments/{{segmentId}}/shopper-profiles
X-Auth-Token: {{ACCESS_TOKEN}}
Accept: application/json
Retrieve segments for a shopper profile
To find all segments associated with a given shopper profile, use the Get all segments for a shopper profile endpoint. Include the id
of the shopper profile as a path parameter.
GET https://api.bigcommerce.com/stores/{{STORE_HASH}}/v3/shopper-profiles/{{shopperProfileId}}/segments
X-Auth-Token: {{ACCESS_TOKEN}}
Accept: application/json
Retrieve shopper profile and segments for a customer
To discover whether a customer is already associated with a shopper profile and segments, use the Get customers endpoint. Pass the include
query parameter with shopper_profile_id
and segment_ids
as in its comma-separated list of values.
Targeting a segment with a promotion
You can use the Promotions standard editor in the store control panel to target the segments you create with the Customer Segmentation API.
Promotions standard editor
To create a promotion in the store control panel, go to Marketing > Promotions > Create > With standard editor. For more detailed information on creating a promotion, visit the standard editor (opens in a new tab) article in our Support Center.
When you set up targeting rules for a promotion, the Customer Segment field is available as an option.
The standard editor supports both inclusion and exclusion targeting rules, such as the following:
- Using the is conditional, a promotion can target segments of shoppers who are in segment A and/or segment B.
- Using the is not conditional, a promotion can target segments of shoppers who are in neither segment A nor segment B.
To learn more about promotion targeting rules, visit the standard editor (opens in a new tab) article in our Support Center.
Resources
Articles
- Customer Segmentation API Overview
- Definitions and Logical Relationships
- Promotions API
- Promotions standard editor (opens in a new tab) (Support Center)
Customer Segmentation reference
- Customer Segmentation V3 API Reference Overview
- Create segments
- Create shopper profiles
- Add shopper profiles to a segment
- Update Segments
- Remove shopper profiles from a segment
- Delete segments
- Get all shopper profiles in a segment
- Get all segments for a shopper profile