Pumpjack Dataworks Analytics SDK

Tracking Events

Tracking events will be done via functions specific to the event type you wish to track.

import * as pjdwsdk from '@pjdw/analytics-web-sdk';

click() function

Tracks a user click

Signature:
export declare function click(label: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
labelstringThe label to associate to the click
otherAttrsAdditionalEventDataAdditional attributes to send with the event
Returns:

void

link() function

Tracks a user opening a link outside of the current domain

Signature:
export declare function link(url: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
urlstring
otherAttrsAdditionalEventDataAdditional attributes to send with the event
Returns:

void

submitted() function

Tracks a form submission and it's respective values.

Signature:
export declare function submitted(
label: string,
formVals: any,
otherAttrs?: AdditionalEventData
): void;

Parameters

ParameterTypeDescription
labelstringTracking form submissions and their values
formValsanyobject containing the form's values
otherAttrsAdditionalEventDataAdditional attributes you wish to send with the event
Returns:

void

receivedPush() function

Tracks a push notification received by your service worker and displayed to the user. (push event)

Signature:
export declare function receivedPush(label: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
labelstringThe label to send with the event
otherAttrsAdditionalEventDataAdditional attributes to send with the event
Returns:

void

openedPush() function

Tracks when a user has opened a push notification. (notificationclick event)

Signature:
export declare function openedPush(label: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
labelstringThe label to send with the event
otherAttrsAdditionalEventDataAdditional attributes to send with the event
Returns:

void

viewed() function

Tracks a page/screen view. Page views are automatically tracked by default unless otherwise specified when initializing the SDK.

Signature:
export declare function viewed(screenName: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
screenNamestringThe name/label you wish to assign to this page
otherAttrsAdditionalEventDataAdditional attributes you can set
Returns:

void

searched() function

Tracks a user searching for something within your website.

Signature:
export declare function searched(searchText: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
searchTextstringThe text the user searched for
otherAttrsAdditionalEventDataAdditional attributes you wish to add about the event
Returns:

void

purchased() function

Tracks a purchase within your website.

Signature:
export declare function purchased(transactionId: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
transactionIdstringThe id of the transaction/order
otherAttrsAdditionalEventDataAdditional attributes you wish to send with the event
Returns:

void

authenticated() function

This should be called any time a user **logs in** to your website. This is separate from identify (which should be called whenever your app initializes with an authenticated user, i.e. the authentication token has not expired) and should only be called when the user authenticates/re-authenticates to your website.

Signature:
export declare function authenticated(label?: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
labelstringThe label you wish to send with this
authenticated
event
otherAttrsAdditionalEventDataAdditional attributes you wish to include
Returns:

void

loggedOut() function

This should be called any time a user logs out of your website. It will end the current session and start a new session.

Signature:
export declare function loggedOut(label?: string, otherAttrs?: AdditionalEventData): void;

Parameters

ParameterTypeDescription
labelstringThe label you wish to send with this
loggedout
event
otherAttrsAdditionalEventDataAdditional attributes you wish to include
Returns:

void

AdditionalEventData interface

Signature:
export interface AdditionalEventData

Properties

PropertyTypeDescription
category?string(Optional) A category to assign to this event
end_time?Date(Optional) End time of the event (only applicable for timed events like watching videos and listening to audio)
meta?object(Optional) Additional data you wish to send with the event. Key/value pairs.
start_time?Date(Optional) Start time of the event