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

›Integration Examples

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
  • Security
Edit

In-transaction/cart integration

The in-transaction/cart integration notifies your frontend whenever a customer selects a Rokt upsell opportunity, and allowing for the change to be reflected in a customer's cart. This is achieved by listening to the UPDATE_CART_ITEM_MESSAGE event of a placement, which is triggered every time a customer makes changes to selected items on the Rokt side.

Additionally, you can provide extra information using Rokt.setAttributes to better tailor offers to a customer. In some cases, depending on your catalog provider, additional information may be required for Rokt to retrieve catalog items.

rokt.onLoaded(function(rokt) {
  // (...) existing integration logic

  rokt.getPlacements().then((placements) => {
    placements.forEach((placement) => {
      placement.on('UPDATE_CART_ITEM_MESSAGE').subscribe(function (update) {
      // Below you should provide your code to reflect changes to your cart
      clientCart.updateCart(update.updatedItem, update.oldItem);
    });
   });
  });

  rokt.setAttributes({
    // attributes required by Rokt to retrieve the catalog items 
    eventId: 'eventId',
    venueName: 'venueName',
    // any additional attributes
    email: 'email',
  });
});

Checking placement availability

This extension involves your backend issuing a call to Rokt to check if any placements are available. You can then decide if your upsell page should be displayed or skipped. In this scenario, your pages have most likely already been generated on the backend, and you have already passed your customer data to Rokt in the initial call. Since that call may have already generated your session ID, the Rokt JavaScript API requires you to pass your session ID to the Rokt.init method so both interactions can be paired together for identification and performance reasons.

rokt.onLoaded(function(rokt) {
  rokt.init({
    sessionId: 'uniqueSessionId', // session ID generated by Rokt backend
  });
  
  rokt.setAttributes({
    // attributes required by Rokt to retrieve the catalog items 
    eventId: 'eventId',
    venueName: 'venueName',
    // any additional attributes
    email: 'email',
  });
});

See Rokt.init for more details on the init method.

← Brand conversion integrationEvent-based integration →
  • Checking placement availability
RESOURCES
DocumentationUser GuideSDKAPIIntegration PartnersHelp
COMPANY
About UsContact UsCareersEngineering Blog
Rokt Documentation
Copyright © Rokt 2021 - All Rights Reserved