Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

Dev Guide
Dev GuideUser GuidesGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

CampaignEvents

OCP App SDK


OCP App SDK / CampaignEvents

Class: CampaignEvents

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

A class to help batch and send campaign related events

Constructors

Constructor

new CampaignEvents(identifierField, tracking, type?): CampaignEvents

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

Parameters

identifierField

string

the 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.

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.

type?

string

Returns

CampaignEvents

Properties

tracking

tracking: Partial<CampaignTracking>

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

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.

Methods

click()

click(identifier, ts?, data?): Promise<void>

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

Send a campaign click event

Parameters

identifier

string

the identifier value / target identifier value related to this event

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


delivery()

delivery(identifier, ts?, data?): Promise<void>

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

Send a campaign delivery event

Parameters

identifier

string

the identifier value / target identifier value related to this event

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


disengage()

disengage(identifier, ts?, data?): Promise<void>

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

Send a campaign disengage event

Parameters

identifier

string

the identifier value / target identifier value related to this event

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


engage()

engage(identifier, ts?, data?): Promise<void>

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

Send a campaign engage event

Parameters

identifier

string

the identifier value / target identifier value related to this event

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


event()

event(identifier, action, ts?, data?): Promise<void>

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

Send a campaign related event

Parameters

identifier

string

the identifier value / target identifier value related to this event

action

CampaignAction

the campaign action

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


flush()

flush(): Promise<void>

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

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

Returns

Promise<void>


hardBounce()

hardBounce(identifier, reason, ts?, data?): Promise<void>

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

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.

Parameters

identifier

string

the identifier value / target identifier value related to this event

reason

string

a human readable reason for the hard bounce

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


open()

open(identifier, ts?, data?): Promise<void>

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

Send a campaign open event

Parameters

identifier

string

the identifier value / target identifier value related to this event

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


optIn()

optIn(identifier, reason, ts?, data?): Promise<void>

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

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.

Parameters

identifier

string

the identifier value / target identifier value related to this event

reason

string

a human readable reason for the opt-in

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


optOut()

optOut(identifier, reason, ts?, data?): Promise<void>

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

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.

Parameters

identifier

string

the identifier value / target identifier value related to this event

reason

string

a human readable reason for the opt-out

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>


softBounce()

softBounce(identifier, reason, ts?, data?): Promise<void>

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

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.

Parameters

identifier

string

the identifier value / target identifier value related to this event

reason

string

a human readable reason for the soft bounce

ts?

the time of the event. If left blank, the recevied time will be used.

string | number | Date

data?

EventData

additional event data to add to the event

Returns

Promise<void>