Skip to content
Docs
/
Guides
/
Segmentation with variables

Segmentation with variables

Keeping track of your contacts is important. You can use variables and linked data to segment your contacts.

Adding data to a contact

Adding data to contacts is easy. By adding the data parameter when sending an event, you can add any data you want to a contact. We will be using this data to create a series of segments.

await fetch('https://api.useplunk.com/v1', {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer API_KEY",
    },
    body: JSON.stringify({
        "event": "new-project",
        "email": "hello@useplunk.com",
        "data": {
            "plan": "pro",
            "joined": "beta",
            "hasClaimedTrial": "true"
        }
    }),
});

By adding just some of these fields to our contacts, we can create powerful segments that we want target with campaigns in the future.

Sending a campaign to a segment

When creating a new campaign, open up the advanced selector and use the data filters to select a specific segment.

In our example, we have selected all contacts that have the plan variable set to pro.

A segmented campaign using the advanced selector
Last updated on November 4, 2022