# User Segments with Storyly

This guide shows how to use Story Labeling to target your user segments.

You can also check out the demo on GitHub

Storyly Demo for Swift (opens new window)

Storyly Demo for Objective-C (opens new window)

Before you begin

You need to have the working Storyly setup as described in Initial SDK Setup

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

# 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 ["married", "Europe"] by enabling Labels checkbox. You may use AND , OR options according to your targeting conditions.

# Passing Segments to Storyly SDK

In Storyly SDK, labels are called segments, and the process is called StorylySegmentation. The application must set ["married", "Europe"] in segments parameters in StorylyInit class while initializing the Storyly SDK.

StorylyInit(storylyId: String, segmentation: StorylySegmentation)

In StorylySegmentation class, the segments parameter takes a set of strings that will be used in the process of segmentation to show specific story groups to the users.

StorylySegmentation(segments: Set<String>)
or
StorylySegmentation(segments: Set<String>,
                    isDynamicSegmentationEnabled: Bool,
                    dynamicSegmentationCallback: StorylyDynamicSegmentationCallback?)

# Example Usage

  • If you do not give any parameters to segments, Storyly SDK will show all active story groups with/without labels. This is the default behavior.
  • If you use AND condition for ["married", "europe"] labels in Audience, Storyly SDK will show the story group if you give ["married"] and ["europe"] parameters to segments. In this case, Storyly SDK will also show the story groups without labels.
  • If you use OR condition for ["married", "europe"] labels, Storyly SDK will show the story group if you give ["married", "europe"], ["married"] and ["europe"] parameters to segments. In this case, Storyly 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.