Skip to main content

Tags

Tags allow you to segment and target content dynamically. When tags are set in the SDK, only stories, In-App Messages, onboardings, and banners matching the active tags will be displayed to the user.

Pay attention

There are several limitations on the list of tags that can be passed to the InAppStory SDK:

  1. Allowed characters: tags can only contain letters, digits, underscores (_), and dashes (-);
  2. Maximum size: the final comma-separated string, when URL-encoded, must not exceed 3999 bytes.

If invalid tags are passed, a warning is logged to the console (InAppStory.tags) and the invalid tags are dropped gracefully rather than throwing an exception.

Setting tags at init

Pass tags in the config when you create the manager. They apply immediately to all content:

const storyManager = await StoryManager.create({
apiKey: '<your-api-key>',
tags: ['tag1', 'tag2'],
});

Updating tags at runtime

setTags replaces the whole tag list:

storyManager.setTags(['tag1', 'tag2']);

addTags appends tags to the current list without replacing it:

storyManager.addTags(['tag1']);

removeTags drops specific tags from the current list:

storyManager.removeTags(['tag2']);
tip

Call setTags / addTags before opening a reader or rendering a list — content is filtered by the tags active at load time.