# User Segments with Storyly

This guide shows you how to show specific story groups using labels.

We will create a Story Group and this Story Group will be shown the users whose segments are ["fr", "france"].

# Set Your Labels in Storyly Dashboard

In the Storyly Dashboard, while creating story groups, you will see an option called Audience. Here you can set your labels ["fr", "france"] by enabling Labels checkbox. You may use AND , OR options according to your targeting conditions.

# Passing Segments to Storyly Web SDK

In the Storyly library, labels are called segments. The Web application must set ["fr", "france"] in segments parameter in init method while initializing the Storyly Web SDK. As it can be seen below, the Storyly library init method has a parameter called segments, which has the following definition:

  storylyWeb.init({    
    ...
    segments: ["fr", "france"]
  });

In the Storyly library, the segments parameter takes an array of strings that will be used in the process of segmentation to show specific story groups to the users. If a label of the story group in the dashboard is a subset of your segments given to init method, Storyly library will show that story group. For basic targeting, it is enough to set the segments parameter.

You can also change segments on the go as follows:

  setSegments(['segment', 'segment2'])

# Example Usage

  • If you do not give any parameters to segments, Storyly Web SDK will show all active story groups with/without labels. This is the default behavior.
  • If you use AND condition for ["fr", "france"] labels in Audience, Storyly Web SDK will show the story group if you give ["fr"] and ["france"] parameters to segments. In this case, Storyly Web SDK will also show the story groups without labels.
  • If you use OR condition for ["fr", "france"] labels, Storyly Web SDK will show the story group if you give ["fr", "france"], ["fr"] and ["france"] parameters to segments. In this case, Storyly Web SDK will also show the story groups without labels.
  • If you set an empty value to the segments, only the story groups without labels will be shown.