Skip to main content

Selection

Overview

Object representing a Rokt selection available as a result of IntegrationLauncher.selectPlacements.

Methods

close

close(): Promise<void>

Closes all placements in the selection. Depending on if Rokt's selection process is still in progress, the method either:

  • removes placements already added on a page
  • prevents placements from being added in the first place

Returns: Promise<void>


getPlacements

getPlacements(): Promise<Array<Placement>>

Gets all placements returned for the selection. The method returns as soon as Rokt's selection process has concluded there are placements available to display on a page, but before the placements are loaded onto the page.

In case there are no placements available for the page, the method resolves with an empty array. If for any reason selection process fails the method rejects the promise with an error.

Returns: Promise<void>


on

on<T>(event: string): Subscriber<SelectionEvent<T>>

Allows subscribing to events with a specific name coming from any placement in the selection. The method is effectively subscribing to Placement.on invoked for each of the placements.

Parameters:

NameTypeDescription
eventstringName of the event to subscribe to

Returns: Subscriber<T>


ready

ready(): Promise<T>

Allows waiting for each placement to become ready. Effectively the same as waiting for each Placement's ready in the selection to resolve.

If any of the placements in the selection for any reason fails to be loaded, the promise will reject with an error.

Returns: Promise<void>


send

send<T>(name: string, data?: T): Promise<void>

Allows sending an event to each placement. Effectively the same as invoking Placement.send for each placement in the selection.

Returned promise will be resolved once all placements handle the message.

Parameters:

NameTypeDescription
namestringName of the event
dataTExpected payload for a given event

Returns: Promise<void>


setAttributes

setAttributes(): Promise<void>

Allows setting additional attributes for the selection.

For relevancy purposes all attributes should be sent while making the selection. The method allows disclosing unhashed values if the hashed attributes were initially sent with the selection in the two step data integration.

Returns: Promise<void>

Properties

context

context : SelectionContext

Context of the selection done by Rokt.

Was this article helpful?