Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Analytics (React Native)

Video playback events

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

import {
  FireworkSDK,
  type VideoPlaybackEvent,
  type VideoPlaybackDetails,
} from 'react-native-firework-sdk';

FireworkSDK.getInstance().onVideoPlayback = (event: VideoPlaybackEvent) => {
  const details: VideoPlaybackDetails = event.info;
  console.log(event.eventName, details.videoId, details.hashtags ?? []);
};

Event details

The playback callback receives a VideoPlaybackEvent with this structure:

interface VideoPlaybackEvent {
  eventName: VideoPlaybackEventName;
  info: VideoPlaybackDetails;
}

eventName identifies the playback action, such as VideoPlaybackEventName.Start, Pause, Complete, or ClickCTA. Video details are in event.info for playback events, in event.video for shopping and custom CTA callbacks, and directly in each array element for videos-loaded callbacks.

The fields of VideoPlaybackDetails are listed below. ? means the field may be omitted; null is also allowed where shown. Availability depends on the event and platform.

Field
Type
Description

videoId

string

Unique video identifier.

duration?

number | null

Total video duration.

caption?

string | null

Video caption.

badge?

string | null

Video badge type.

playerSize?

VideoPlayerSize | null

Player dimensions: { width: number; height: number }.

hasCTA?

boolean | null

Whether the video has a call-to-action.

progress?

number | null

Amount of time the video was playing at the time of the event.

ctaActionType?

string | null

CTA action type, such as buy, download, view, or book. iOS only.

ctaActionURL?

string | null

URL associated with the CTA button.

feedId?

string | null

Associated feed identifier.

videoType?

VideoType | null

VideoType.Ad ('ad'), VideoType.Video ('video'), or VideoType.Livestream ('livestream').

liveStreamStatus?

LiveStreamStatus | null

Livestream status when videoType is VideoType.Livestream: Idle ('idle'), Live ('live'), Completed ('completed'), or Replay ('replay').

hashtags?

string[] | null

Video hashtags. An empty array when the video has none.

Video feed click events

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

Live stream events

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

Live stream chat events

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

Product click events

Outstream PDP

If you would like to customize the product click event handling, you could use onCustomTapProductCard to support this use case. For example, you could open your product detail page when the user clicks on the product. We call this outstream PDP.

Instream PDP

If you would like to use the SDK default behavior to handle the product click event, you could use onClickProduct to support this use case. The SDK default behavior is opening Firework product detail page when the user clicks on the product. We call this instream PDP.

Shopping CTA click events

You could use onShoppingCTA callback to receive shopping CTA click events.

Video overlay CTA click events

  1. If you would like to customize the overlay CTA click event handling, you could use onCustomCTAClick to receive video overlay CTA click events. For example, you could open your product detail page when the user clicks on the overlay CTA.

  2. If you would like to use the SDK default behavior to handle the overlay CTA click event, you could use onVideoPlayback(eventName is VideoPlaybackEventName.ClickCTA) to receive video overlay CTA click events. The SDK default behavior is opening the CTA link using the SDK webview or system browser when the user clicks the overlay CTA.

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.

Call trackPurchase once per completed order, on the order confirmation step. Report every purchase without any client-side filtering — Firework identifies attributed vs non-attributed purchases server-side.

Required fields

For Shopping V2 purchase tracking (parity with the Web analytics.purchase API), the following fields are required:

Field
Description

orderId

A unique identifier for the user's order.

value

The final amount paid, including taxes, shipping, and discounts. Sent as order_value.

currencyCode

The ISO 4217 currency code of the purchase value, e.g. USD.

subtotal

The items cost before discounts, taxes, and shipping.

products

The purchased items, must be non-empty. Sent as line_items.

Each entry in products requires price (the unit price, including line-level discounts), quantity, and at least one of sku or extProductId. sku can be the SKU, barcode, GTIN, MPN, or external id; when present it takes precedence over extProductId.

If any required field is missing, the SDK still forwards the event but logs a warning listing the missing fields.

Sample code

Conversion tracking

Get feed id for VideoFeed and StoryBlock during component initialization

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

Get feed id from event callbacks

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

Last updated

Was this helpful?