Rokt
This object provides the entry point to integrate with Rokt solutions.
Properties
cart
• cart: Cart
Provides access to cart integration
see
Cart
version
• version: string
Rokt JavaScript API version.
widget
• widget: Widget
Provides access to widget integration
see
Widget
Methods
closeAll
▸ closeAll(): void
Close/Unload all placements on the page
Returns: void
init
▸ init(configuration
: RoktConfiguration): void
Sets information allowing to identify you or your consumer.
see
RoktConfiguration on details of available parameters.
Parameters:
Name | Type | Description |
---|---|---|
configuration | RoktConfiguration | Configuration object |
Returns: void
onFailure
▸ onFailure(failureCallback
: OnFailureCallback): 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:
Name | Type | Description |
---|---|---|
failureCallback | OnFailureCallback | Callback to be triggered when Rokt object is ready |
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:
Name | Type |
---|---|
rokt | Rokt |
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:
Name | Type | Description |
---|---|---|
attributes | Attributes | Dictionary 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:
Name | Type | Description |
---|---|---|
attributes | Attributes | Dictionary with data such as first name, last name, email, etc. |
Returns: void