Tracking Media
The SDK enables you to track media either listened to or watched.
The watched
and listened
functions, when called, will start an internal
timer that will end when the implementer calls the end
method on the object
that is returned from either of those functions. On end
, the event with its
duration will be sent.
Example
// When a user starts watching a videoconst videoEvent = pjdwsdk.watched('Video name here');// When the user finishes watching the video, call `end`.// This will send and finalize the event.videoEvent.end();
watched() function
Track a user watching a video. This returns a Media
object that has an end
method that should be called when the user is done watching the video.
export declare function watched(label: string, otherAttrs?: AdditionalEventData): Media;
Parameters
Parameter | Type | Description |
---|---|---|
label | string | The label to describe the unique video the user is watching |
otherAttrs | AdditionalEventData | Additional attributes you wish to send with the event |
Media
- An object with an
end
method to call when the user is done watching.
listened() function
Track a user listening to audio. This returns a Media
object that has an end
method that should be called when the user is done listening to the audio.
export declare function listened(label: string, otherAttrs?: AdditionalEventData): Media;
Parameters
Parameter | Type | Description |
---|---|---|
label | string | The label to describe the unique audio the user is listening to |
otherAttrs | AdditionalEventData | Additional attributes you wish to send with the event |
Media
- An object with an
end
method to call when the user is done listening.