# Storyly Events

This section shows you how to observe Storyly's basic functionality events. In order to get notification about these basic events, you should register callback events, which you have registered in Initial SDK Setup.

# StorylyStoryShown Event

This event will let you know that stories are starting to be shown to the users. In order to notified about this event, use the following example:

StorylyView(
    ...
    storylyStoryShown: () {
        print("storylyStoryShown")
    }
)

# StorylyStoryDismissed Event

This event will let you know that the user dismissed the current story while watching it. In order to notified about this event, use the following example:

StorylyView(
    ...
    storylyStoryDismissed: () {
        print("storylyStoryDismissed")
    },
)

# Interactive Events with Tracking ID

This guide shows you how to get reactions of users from specific interactive components. You can use the following function to get reactions of your users:

StorylyView(
    ...
    storylyUserInteracted: (eventPayload) {
        print("storylyUserInteracted ${eventPayload['storyComponent']['type']}")
    },
)

Here is the sample format of parameters:

{
  "storyGroup": {
    "id": 1,
    "title": "...",
    "index": 1,
    "seen": true,
    "iconUrl": "...",
    "stories": [
      {
        "id": 1,
        "title": "...",
        "index": 1,
        "seen": true,
        "media": {
          "type": 1,
          "url": "...",
          "actionUrl": null
        }
      }
    ]
  },
  "story": {
    "id": 1,
    "title": "...",
    "index": 1,
    "seen": true,
    "media": {
      "type": 1,
      "url": "...",
      "actionUrl": null
    }
  },
  "storyComponent": {
    "type": "emoji",
    "emojiCodes": [
      "😡",
      "😢",
      "😊",
      "😍",
      "👍"
    ],
    "selectedEmojiIndex": 2,
    "customPayload": ""
  }
}

storyComponent parameter informs your application about the interacted component and the details of the interaction. For instance, if a user answers a quiz, the payload will include what the right answer is and what the user's answer is. The structure of storyComponent is different for each of the interactive components.

WARNING

This event only notifies your application about Emoji, Rating, Poll, Quiz, and Countdown reactions.

# Tracking ID

From Storyly Studio, application owners can give tracking ids to the interactive components. This id can be received using the customPayload field of storyComponent.