Pumpjack Dataworks Analytics SDK

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 video
const 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.

Signature:
export declare function watched(label: string, otherAttrs?: AdditionalEventData): Media;

Parameters

ParameterTypeDescription
labelstringThe label to describe the unique video the user is watching
otherAttrsAdditionalEventDataAdditional attributes you wish to send with the event
Returns:

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.

Signature:
export declare function listened(label: string, otherAttrs?: AdditionalEventData): Media;

Parameters

ParameterTypeDescription
labelstringThe label to describe the unique audio the user is listening to
otherAttrsAdditionalEventDataAdditional attributes you wish to send with the event
Returns:

Media

  • An object with an end method to call when the user is done listening.