Applying discounts to customer saved searches using the Segmentation API
This tutorial teaches you how to use the Segmentation API to apply discounts to existing customerSavedSearches
. The Segmentation API enables you to filter out specific customers for marketing, analytics, and reporting purposes
.
A list of customer segment IDs is automatically created from existing customerSavedSearches
to ease the migration from using customerSavedSearches
to customer segments
. If a customerSavedSearch
is unmigratable, then segments
aren't created for it.
This tutorial is for app developers who develop an app that uses customer saved searches.
Requirements
Anchor link to section titled "Requirements"- The shop you're working with has
customerSavedSearches
. - You've created an app.
- Your app has access to the following access scopes:
read_customers
write_customers
- You've authenticated your app.
- You've created customers in your development store.
What you'll learn
Anchor link to section titled "What you'll learn"In this tutorial, you'll learn how to do the following tasks:
Step 1: Retrieve a list of customerSegments
from a shop
Anchor link to section titled "Step 1: Retrieve a list of customerSegments from a shop"You can use the segments
query from the GraphQL Admin API to return a list of customerSegments
from a shop. If the shop you are querying has customerSavedSearches
, and the customerSavedSearches
are compatible with customerSegments
, then the customerSavedSearches
are automatically converted to customerSegments
.
You don't need to manually search for compatible customer saved searches in your shop, because the segments
query returns only the compatible customer saved searches as customer segments.
To retrieve a list of the first 250 customer segments from a shop, including compatible customer saved searches, use the following GraphQL query:
Step 2: Apply discounts to customerSegments
Anchor link to section titled "Step 2: Apply discounts to customerSegments"In Step 1, you retrieved a segmentId
list from a shop. You can specify which segmentId
you want to apply a discount to by using the discountCodeBasicCreate
mutation.
To apply a 10%-off all items discount, named "Discount", to two customerSegments
, use the createBasicDiscount
mutation:
- For more examples of how you can use the Segmentation API, refer to the Examples section.