Sending Events

This section shows you how to send the JOIN Stories events to specific data platforms. You can use the following function of JOINStoriesListenerDelegate to redirect the JOIN Stories events to your data platform :

import JOINStoriesSDK

class YourViewController: UIViewController {

   override func viewDidLoad() {
        super.viewDidLoad()
       JOINStoriesListener.setDelegate(delegate: self)
   }
}

extension YourViewController: JOINStoriesListenerDelegate {
    func onTriggerAnalyticsCallback(model: TriggerAnalyticsModel) {}
    func onPlayerAnalyticsCallback(model: PlayerAnalyticsModel) {}
}

import JOINStoriesSDK

struct YourView : View {
    
   @StateObject var viewModel = YourViewModel()
    
    var body: some View {
        Text("Hello, world!")
    }
}

class YourViewModel: ObservableObject {
    init() {
        JOINStoriesListener.setDelegate(delegate: self)
    }
}

extension YourViewModel: JOINStoriesListenerDelegate {
    func onTriggerAnalyticsCallback(model: TriggerAnalyticsModel) {}
    func onPlayerAnalyticsCallback(model: PlayerAnalyticsModel) {}
}

🚧

Analytics sender

When integrating, you need to be aware of the widget's lifecycle, as the widget may send events several times during use if it is destroyed and recreated, in the case of a dynamic list.

JOIN Stories Events

In order to get notification about JOIN Stories events, you should override the following functions in JOINStoriesListenerDelegate. The events are separated between trigger events (onTriggerAnalyticsCallback called) and player events (onPlayerAnalyticsCallback called).

Trigger Events

onTriggerAnalyticsCallback returns the following payload for each event:

public struct TriggerAnalyticsModel {
    public var eventOwner: String? // owner of the story (equal teamId)
    public var cpWidgetAlias: String // Alias of the trigger
    public var cpWidgetVersion: String // Version of the SDK
    public var date: Int64 // Current UNIX Timestamp in ms
    public var eventCategory: String = "widget"
    public var eventType: TriggerAnalyticsEventType // The event type
    public var eventTypeName: String // The event type name
    public var storyClicked: String // The story id - only for click events
}

Stories Fetched Event

Each time the trigger fetch the list of stories from the API, a Stories fetched event is sent:

event: .storiesFetched

Trigger Mounted Event

Each time the trigger is instantiated, a Trigger Mounted event is sent:

event: .widgetMounted

Trigger Visibility 50% Event

After instantiation, the first time the trigger is visible at least on 50% of its height, a Trigger Visible 50% event is sent:

event: .componentVisible50

Trigger Visibility 75% Event

After instantiation, the first time the trigger is visible at least on 75% of its height, a Trigger Visible 75% event is sent:

event: .componentVisible75

First Click on Trigger Event

After instantiation, the first time the trigger is clicked to open the player, a First Click on Trigger event is sent:

event: .firstClickOnWidget

It also contains the following value: storyClicked: STORY_ID

Additional Click on Trigger

Each time the trigger is clicked after the first click (see previous event), an Additional Click on Trigger event is sent:

event: .additionalClickOnWidget

It also contains the following value: storyClicked: STORY_ID

Player Events

onPlayerAnalyticsCallback returning the following payload for each event:

public struct PlayerAnalyticsModel {
    public var storyPageCount: Int // Number of chapter of the story
    public var eventOwner: String? // owner of the story (equal teamId)
    public var storyId: String? // ID of the story
    public var date: Int64 // Current UNIX Timestamp in ms
    public var eventCategory: String = "story",
    public var cpIndex: Int? // Index of the current chapter: from 0 to N
    public var cpTitle: String? // Title of the story
    public var eventType: PlayerAnalyticsEventType // The event type
    public var eventTypeName: String // The event type name
}

Chapter View Event

Each time a chapter (equivalent to story page) starts playing, a Chapter View event is sent:

event: .storyPageVisible

Last Chapter View Event

Each time the last chapter (last story page) starts playing, a Last Chapter View event is sent:

event: .storyLastPageVisible

Click Call To Action Event

Each time the user clicks on a CTA, a Click Call To Action event is sent:

event: .storyClickOnCallToAction