๐ŸŽฏAPI-based Segmentation Quickstart Guide

This guide covers everything you need to know about programmatically managing user segments for your CustomerGlu campaigns.

What is Segmentation?

Segmentation lets you target specific campaigns to specific users. With our APIs, you can add users to campaigns, check their status, and remove them when needed - all programmatically.

Prerequisites

Before you start:

  • โœ… Get your API key from the CustomerGlu Dashboard

  • โœ… Note your Campaign IDs from the Campaigns section

  • โœ… Have your User IDs ready (same as Registration API)

API Endpoints

1. Add a User to a Campaign

Request:

POST https://api-us.customerglu.com/segment/:campaignId/user/add
Content-Type: application/json
X-API-KEY: your-api-key

{
    "userId": "user-123"
}

Response:

Effect: User immediately starts seeing the campaign and can earn associated rewards.

2. Check User's Campaign Status

Request:

Response:

3. Remove a User from a Campaign

Request:

Response:

Effect: Campaign stops appearing for this user; they stop earning campaign rewards.

Implementation Examples

Personalized Onboarding

A/B Testing

Regional Endpoints

Select the appropriate base URL for your region:

  • ๐Ÿ‡บ๐Ÿ‡ธ US: https://api-us.customerglu.com

  • ๐Ÿ‡ฆ๐Ÿ‡ช UAE: https://api-me.customerglu.com

  • ๐Ÿ‡ฎ๐Ÿ‡ณ IN: https://api-in.customerglu.com

Error Handling

The API returns standard HTTP status codes. Here are common errors and solutions:

Solution: Verify your API key is correct and active.

Solution: Double-check the campaign ID exists and is active.

Best Practices

  1. Check Before Modifying: Use the status endpoint to avoid redundant operations

  2. Error Handling: Implement proper error handling with retries for production systems

  3. Webhooks Integration: Connect user events to segmentation API calls for real-time targeting

  4. Caching: Cache segment membership locally for frequently checked users

  5. Logging: Track API calls and responses for debugging and audit purposes

Need Help?

Run into issues? Check these common troubleshooting steps:

  1. Verify API key permissions in your CustomerGlu Dashboard

  2. Ensure campaign IDs are correct and campaigns are active

  3. Check that user IDs match those in your CustomerGlu account

  4. Confirm you're using the correct regional endpoint

For more assistance, contact our developer support team via Slack

Last updated

Was this helpful?