Rokt Documentation
  • Documentation
  • User Guide
  • SDK
  • API
  • Third-Party Integrations
  • Help

›API

Getting Started

  • Introduction

Web SDK

  • Overview
  • Architecture
  • Integrating the Web SDK
  • Integration Examples

    • Confirmation Page Integration
    • Preparative Iframe
    • Page Identifier
    • Single Page Applications
    • Brand Conversion Integration
    • In Transaction/Cart Integration
    • Event-based Integration
    • Sandbox Integration
  • Integration Best Practices
  • Attributes
  • Security
  • Mobile In-App Web Pages
  • API

    • Rokt
    • Attributes
    • CartItem
    • Configuration
    • Placement
    • Subscriber
    • TriggerPageChangeOptions
    • Unsubscriber

iOS SDK

  • Overview
  • Version
  • Integrating the SDK

    • Integrating and Initializing the SDK
    • Launching an Overlay Placement
    • Launching an Embedded Placement
    • Recording a Brand Conversion
    • Sandbox Integration
  • Attributes
  • Security

Android SDK

  • Overview
  • Version
  • Integrating the SDK

    • Integrating and Initializing the SDK
    • Launching an Overlay Placement
    • Launching an Embedded Placement
    • Recording a Brand Conversion
    • Sandbox Integration
  • Attributes
  • Security

React Native SDK

  • Overview
  • Version
  • Integrating the SDK

    • Integrating and Initializing the SDK
    • Launching an Overlay Placement
    • Launching an Embedded Placement
    • Recording a Brand Conversion
    • Sandbox Integration

    Attributes

    • Core Attributes
    • Vertical Attributes
  • Security
Edit

Rokt

Rokt object provides the entry point to integrate with Rokt's solution.

Methods

closeAll

▸ closeAll(): void

Close/Unload all placements on the page

Returns: void


getPlacements

▸ getPlacements(): Promise‹Array‹Placement››

Returns a list of selected placements

Returns: Promise‹Array‹Placement››


hashString

▸ hashString(value: string): Promise‹string›

Convenience method hashing a string using SHA-256. Since Rokt manipulates string before hashing it is recommended to use the provided method instead of implementing on your own.

Parameters:

NameTypeDescription
valuestringstring to hash

Returns: Promise‹string›


init

▸ init(configuration: Configuration): void

Sets information allowing to identify you or your consumer.

see Configuration on details of available parameters.

Parameters:

NameTypeDescription
configurationConfigurationConfiguration object

Returns: void


onFailure

▸ onFailure(failureCallback: function): void

Accepts a callback which will be triggered when Rokt object fails to load/cannot be displayed correctly. For example, this scenario can happen when encountering very old browser that is not supported by Rokt as per agreement with client.

example

rokt.onFailure((reason) => {
  // Use this hook to display error or navigate to another page
});

Parameters:

▪ failureCallback: function

Callback to be triggered when Rokt object is ready

▸ (reason: string): void

Parameters:

NameType
reasonstring

Returns: void


onLoaded

▸ onLoaded(onLoadedCallback: function): void

Accepts a callback which will be triggered once Rokt object has been loaded and is ready to use. Callback will be triggered immediately if Rokt object is already ready.

You can invoke this method multiple times each time passing a unique callback. They will be all executed in the order they were passed once Rokt object is ready to integrate. This approach may be useful in case of Single Page Applications in which integration points may happen in multiple places in the JavaScript code.

example

rokt.onLoaded((rokt) => {
  // Now you can interact with Rokt object
});

Parameters:

▪ onLoadedCallback: function

Callback to be triggered when Rokt object has been loaded

▸ (rokt: Rokt): void

Parameters:

NameType
roktRokt

Returns: void


setAttributes

▸ setAttributes(attributes: Attributes): void

Sets attributes which allow Rokt to better tailor offer to a consumer. Those attributes may include consumer email, first name, last name, etc. Depending on your catalog provider, additional information may be required by Rokt to be able to retrieve catalog items, e.g. for ticketing partners eventId is required.

Rokt.setAttributes performs a shallow merge of passed attributes into the existing attributes.

Since passing browser's user agent is required attributes store its value under userAgent property by default.

default

{
  userAgent: 'Mozilla/5.0 (...)', // window.navigator.userAgent value
}

Parameters:

NameTypeDescription
attributesAttributesDictionary with data such as first name, last name, email, etc.

Returns: void


setFulfillmentAttributes

▸ setFulfillmentAttributes(attributes: Attributes): void

Sets attributes that remains unknown by Rokt until the user accepts any of the offers.

Rokt.setFulfillmentAttributes performs a shallow merge of passed attributes into the existing attributes.

Parameters:

NameTypeDescription
attributesAttributesDictionary with data such as first name, last name, email, etc.

Returns: void


triggerPageChange

▸ triggerPageChange(options: TriggerPageChangeOptions): void

Re-triggers placement selection for a new page.

In case of SPA integrations, Rokt's solution may be displayed on multiple pages or loaded on a page which does not initially shows placements to a user. In this case, Rokt relies on partner to trigger the method to let Rokt know when user reaches page we meant to display placements on.

Parameters:

NameTypeDescription
optionsTriggerPageChangeOptionsOptions for new page.

Returns: void

← Mobile In-App Web PagesAttributes →
  • Methods
    • closeAll
    • getPlacements
    • hashString
    • init
    • onFailure
    • onLoaded
    • setAttributes
    • setFulfillmentAttributes
    • triggerPageChange
RESOURCES
DocumentationUser GuideSDKAPIIntegration PartnersHelp
COMPANY
About UsContact UsCareersEngineering Blog
Rokt Documentation
Copyright © Rokt 2021 - All Rights Reserved