Solved

How to force a segment to update using API?

  • 11 April 2024
  • 1 reply
  • 13 views

Badge +2

Hello.

I have a following setup in my Klaviyo account:
There is a list of profiles and a segment based on that list with some filters. A script runs once every few days and add some profiles to the list and then schedules a campaign based on the segment. The campaign is set to determine recipients at the schedule time.

When a script runs for two consecutive days, it sometimes happens that some users added on day 1 receive also campaign on day 2, although the definition of the segment should filter them out.

Looking at the docs on segment updating (https://help.klaviyo.com/hc/en-us/articles/115005233488) I guess it’s possible that the segment was not updated in time. So here are my questions:

  1. Am I right to assume that the segment is not updated automatically on the capaign schedule time? Can it cause some “out of date” users to receive second email?
  2. Is there a way in the API to force the segment to update?
  3. If I set the campaign to determine recipients on the sent time, will it force the segment to update then?
icon

Best answer by retention 11 April 2024, 22:41

View original

1 reply

Userlevel 7
Badge +58

Hi @piotrekw, welcome back to the community.

I have a few follow-up questions if I understand you correctly:

  • Does your Script create a “Klaviyo Campaign” programmatically to the Segment?
  • Are the Day 1 and Day 2 the only issue you’re trying to resolve?  Are you seeing someone from Day 1, also get campaigns on Day 3? (or later?)
  • What are your Segment Filter Rules?
  • Is the goal just to send a campaign the next day after someone is added to the List (but only if they fall into the Segment Filter rules?) 

If I understand what you’re doing, you are scheduling Campaigns (programmatically via the API) every time you add profiles to the List, for only those that meet your Segment rules.  I’m not sure if doing it programmatically is required for some reason (adding in custom data or logic?), but a few things you can consider:

  • Segmentation processing time can vary based on the the rules you applied.  Klaviyo explains how often Segments are updated based on a few factors that you already pointed out, so i agree with you that may be an issue: Understanding how segments update
  • Use the Smart Sending, and make sure your Smart Sending window is turned on long enough between your automated Campaigns can possibly block someone from getting the emails twice.
  • Add some timing buffer in your Segmentation rule so that people who are added to the List close to a Campaign send time are not part of the Segment. (E.g. Create Date is Before 1 Day ago)

Finally, unless there’s some reason you’re doing it the way you are via a programmatic Campaign send. It seems to me you should just create a Segment Triggered Flow, that sends the “campaign” email through a Flow (and not as a Campaign).

You can put a Time Delay so that it always waits until the next day (at a specific time).  A Segment Triggered Flow will guarantee that a user can go through the Flow exactly once without repeats (even if they exit the Segment and are added back again).  

You can read more about this here:

If you share some screenshots of your Segment, or further explain this “script driven Campaign,” I’d be happy to help further.

 

Reply