Assigning a Segment Programmatically


You might want to assign a visitor to a segment programmatically instead of using the Convert interface options to add it.


  1. Find out the segment id. This is a bit tricky as you have to add the audience (that you have designated as a segment) to an experience to be able to find it. 

    You can find this on the Audience card under the Experience Summary. Please see the image below for an example:

    save image
  2. Code it. Adapt the following example to programmatically add a visitor to a segment:

    See the Pen LJXveq by (@gcrewe) on CodePen.

  3. Test your code as a normal visitor in an incognito browser window and verify that the cookie _conv_v has the segment id recorded on the seg key. You can find more information about the cookie structure in the following article.

keyword: placeVisitorIntoSegment

Need assistance? Start a conversation with our Support Team.

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features