Skip to main content

Scenario

Your Shopify store has thousands of customers with varying purchase histories. You pull customer records with order counts and total spend via GraphQL, segment them into cohorts (new buyers with 1 order, returning buyers with 2–5 orders, VIP buyers with 6+ orders or $500+ spend), and create a Mavera persona for each cohort.

Architecture

Code

Example Output

Error Handling

Shopify returns a THROTTLED error in extensions.cost when you exceed your point budget. Read throttleStatus.currentlyAvailable from each response. When available points fall below query cost, sleep for (cost - available) / restore_rate seconds. Standard stores restore at 50 pts/sec; Plus at 500 pts/sec.
If a persona with the same name exists, the API returns 422. Fetch existing personas with GET /api/v1/personas?name=Shopify+VIP+Customer first, and use PATCH /api/v1/personas/{id} to update instead.