Analytics

Video playback events

As follows, you could set FireworkSDK.getInstance().onVideoPlayback to receive video playback events. The event type is VideoPlaybackEvent.

FireworkSDK.getInstance().onVideoPlayback = (event) {
  if (event != null) {
    switch (event.eventName) {
      case VideoPlaybackEventName.impression:

        /// When video is shown to the user.
        break;
      case VideoPlaybackEventName.start:

        /// Video started.
        break;
      case VideoPlaybackEventName.pause:

        /// Video paused.
        break;
      case VideoPlaybackEventName.resume:

        /// Video resume.
        break;
      case VideoPlaybackEventName.firstQuartile:

        /// Video reached 25%.
        break;
      case VideoPlaybackEventName.midpoint:

        /// Video reached 50%.
        break;
      case VideoPlaybackEventName.thirdQuartile:

        /// Video reached 75%.
        break;
      case VideoPlaybackEventName.complete:

        /// Video reached 100%.
        break;
      case VideoPlaybackEventName.adStart:

        /// When ad video start playing.
        break;
      case VideoPlaybackEventName.adEnd:

        /// When ad video finishes playing.
        break;
      case VideoPlaybackEventName.clickCTA:

        /// When a visitor clicks on CTA button (if available).
        break;
      case VideoPlaybackEventName.clickShare:

        /// When user clicks on "Share" button.
        break;
    }
  }
};

Video feed click events

As follows, you could set FireworkSDK.getInstance().onVideoFeedClick to receive video feed click events. The event type is VideoFeedClickEvent.

FireworkSDK.getInstance().onVideoFeedClick = (event) {
};

Live stream events

As follows, you could set FireworkSDK.getInstance().liveStream.onLiveStreamEvent to receive live stream events. The event type is LiveStreamEvent.

FireworkSDK.getInstance().liveStream.onLiveStreamEvent = (event) {
  if (event != null) {
    switch (event.eventName) {
      case LiveStreamEventName.userDidjoin:
        print("livestream id: ${event.info.id}");
        break;
      case LiveStreamEventName.userDidLeave:
        print("livestream id: ${event.info.id}");
        break;
      case LiveStreamEventName.userSendLike:
        print("livestream id: ${event.info.id}");
        break;
    }
  }
};

Live stream chat events

As follows, you could set FireworkSDK.getInstance().liveStream.onLiveStreamChatEvent to receive live stream chat events. The event type is LiveStreamChatEvent.

FireworkSDK.getInstance().liveStream.onLiveStreamChatEvent = (event) {
  if (event != null) {
    switch (event.eventName) {
      case LiveStreamChatEventName.userSendChat:
        print("livestream id: ${event.liveStream.id}");
        print("message id: ${event.message.messageId} username: ${event.message.username} text: ${event.message.text}");
        break;
    }
  }
};

Purchase tracking

The host app can record a purchase which will help get a full picture of the user journey flow. To do this, call FireworkSDK.getInstance().trackPurchase whenever the purchase happens. The following are the sample codes:

FireworkSDK.getInstance().trackPurchase(
  TrackPurchaseParameters(
    orderId: "<Order ID of User Purchase>",
    value: "total purchase value",
    currencyCode: "e.g. USD",
    countryCode: "e.g. US",
    additionalInfo: <String, String>{
      "additionalKey1": "additionalValue1",
      "additionalKey2": "additionalValue2",
      "additionalKey3": "additionalValue3"
    },
  ),
);

Conversion tracking

Get feed id for VideoFeed and StoryBlock during widget initialization

You could use onVideoFeedGetFeedId callback to get feed id for VideoFeed and StoryBlock during widget initialization. The related reference links are:

Map<String, String> globalMap = <String, String>{};

VideoFeed(
  height: 200,
  source: VideoFeedSource.discover,
  onVideoFeedGetFeedId: (feedId) {
    // The host app could store some custom info based on the feed id,
    // such as widget name, widget type etc.
    globalMap[feedId] = "VideoFeed Widget1";
  },
);

VideoFeed(
  height: 200,
  source: VideoFeedSource.discover,
  onVideoFeedGetFeedId: (feedId) {
    // The host app could store some custom info based on the feed id,
    // such as widget name, widget type etc.
    globalMap[feedId] = "VideoFeed Widget2";
  },
);

StoryBlock(
  height: 200,
  source: StoryBlockSource.discover,
  onStoryBlockGetFeedId: (feedId) {
    // The host app could store some custom info based on the feed id,
    // such as widget name, widget type etc.
    globalMap[feedId] = "StoryBlock Widget1";
  },
);

StoryBlock(
  height: 200,
  source: StoryBlockSource.discover,
  onStoryBlockGetFeedId: (feedId) {
    // The host app could store some custom info based on the feed id,
    // such as widget name, widget type etc.
    globalMap[feedId] = "StoryBlock Widget2";
  },
);

Get feed id and video id from event callbacks

Currently, the host app could get feed id and video id from some event callbacks. For example:

FireworkSDK.getInstance().shopping.onShoppingCTA = async (event: ShoppingCTAEvent) => {
  final feedId = event?.video.feedId
  if (feedId != null) {
    // Get custom info based on the feed id
    final widgetName = globalMap[feedId];
  }
  
  final videoId = event?.video.videoId;
  if (videoId != null) {
    // Use the video id to do custom logic
  }
}

FireworkSDK.getInstance().shopping.onCustomClickCartIcon = async (event) => {
  final feedId = event?.video.feedId
  if (feedId != null) {
    // Get custom info based on the feed id
    final widgetName = globalMap[feedId];
  }
  
  final videoId = event?.video.videoId;
  if (videoId != null) {
    // Use the video id to do custom logic
  }
};

FireworkSDK.getInstance().shopping.onUpdateProductDetails =
    (UpdateProductDetailsEvent? event) async {
  final feedId = event?.video.feedId
  if (feedId != null) {
    // Get custom info based on the feed id
    final widgetName = globalMap[feedId];
  }
  
  final videoId = event?.video.videoId;
  if (videoId != null) {
    // Use the video id to do custom logic
  }
};

FireworkSDK.getInstance().shopping.onCustomTapProductCard = async (event) => {
  final feedId = event?.video.feedId
  if (feedId != null) {
    // Get custom info based on the feed id
    final widgetName = globalMap[feedId];
  }
  
  final videoId = event?.video.videoId;
  if (videoId != null) {
    // Use the video id to do custom logic
  }
};

FireworkSDK.getInstance().onCustomCTAClick = async (event) => {
  final feedId = event?.video.feedId
  if (feedId != null) {
    // Get custom info based on the feed id
    final widgetName = globalMap[feedId];
  }
  
  final videoId = event?.video.videoId;
  if (videoId != null) {
    // Use the video id to do custom logic
  }
}

Last updated