Disclaimer: This website requires JavaScript to function properly. Some features may not work as expected. Please enable JavaScript in your browser settings for the best experience.

Dev Guide
Dev GuideUser GuidesLegal TermsGitHubDevCommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

CampaignEvents

OCP App SDK / CampaignEvents

CampaignEvents

A class to help batch and send campaign related events

Index

Constructors

Properties

Methods

Constructors

constructor()

Signature

new CampaignEvents(identifierField: string, tracking: Partial<CampaignTracking>, type?: string): CampaignEvents;

Parameters

NameTypeDescription
identifierFieldstringthe name of the identifier field used to target the user.
The identifier value provided to a campaign event must be for this identifier field name.
trackingPartial<CampaignTracking>Campaign tracking information to be included on every event.
Use an empty {} if you plan to provide different tracking info for each event,
otherwise a complete CampaignTracking object.
type?string-

Returns

CampaignEvents

Defined in: src/app/lib/CampaignEvents.ts:28

Properties

tracking

Partial<CampaignTracking>

Campaign tracking information to be included on every event.
Use an empty {} if you plan to provide different tracking info for each event,
otherwise a complete CampaignTracking object.

Defined in: src/app/lib/CampaignEvents.ts:30

Methods

click()

Send a campaign click event

Signature

click(identifier: string, ts?: string | number | Date, data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:100

delivery()

Send a campaign delivery event

Signature

delivery(identifier: string, ts?: string | number | Date, data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:80

disengage()

Send a campaign disengage event

Signature

disengage(identifier: string, ts?: string | number | Date, data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:120

engage()

Send a campaign engage event

Signature

engage(identifier: string, ts?: string | number | Date, data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:110

event()

Send a campaign related event

Signature

event(
  identifier: string,
  action: CampaignAction,
  ts?: string | number | Date,
  data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
actionCampaignActionthe campaign action
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:58

flush()

Flush all API batches. You MUST flush before your task exists if you generated any events.

Signature

flush(): Promise<void>;

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:45

hardBounce()

Send a campaign hard bounce event, which means you were unable to deliver AND
the identifier is definitely no longer reachable. E.g., an invalid address.

Signature

hardBounce(
  identifier: string,
  reason: string,
  ts?: string | number | Date,
  data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
reasonstringa human readable reason for the hard bounce
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:132

open()

Send a campaign open event

Signature

open(identifier: string, ts?: string | number | Date, data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:90

optIn()

Send a campaign related opt-in event, such as, when a customer re-subscribes or replies UNSTOP to an SMS.
This is considered a consent opt-in for the identifier.

Signature

optIn(
  identifier: string,
  reason: string,
  ts?: string | number | Date,
  data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
reasonstringa human readable reason for the opt-in
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:201

optOut()

Send a campaign related opt-out event, such as, when a customer unsubscribes or replies STOP to an SMS.
Consent will be revoked on the identifier.

Signature

optOut(
  identifier: string,
  reason: string,
  ts?: string | number | Date,
  data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
reasonstringa human readable reason for the opt-out
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:179

softBounce()

Send a campaign soft bounce event, which means you were unable to deliver,
but the identifier may still be reachable. E.g., the provider is temporarily unavailable.

Signature

softBounce(
  identifier: string,
  reason: string,
  ts?: string | number | Date,
  data?: EventData): Promise<void>;

Parameters

NameTypeDescription
identifierstringthe identifier value / target identifier value related to this event
reasonstringa human readable reason for the soft bounce
ts?string | number | Datethe time of the event. If left blank, the recevied time will be used.
data?EventDataadditional event data to add to the event

Returns

Promise<void>

Defined in: src/app/lib/CampaignEvents.ts:155