React Native SDK Integration — Legacy (Shoppable Ads)
This guide is for the Direct Rokt SDK (@rokt/react-native-sdk). For new integrations, we recommend the React Native SDK Integration guide which uses SDK+.
This guide covers how to integrate Shoppable Ads into your React Native app using the Direct Rokt SDK. Shoppable Ads enable post-purchase upsell offers with in-app catalog browsing and instant checkout (via Apple Pay or Stripe) — all within the Rokt placement.
For the general Rokt React Native SDK reference, see the React Native SDK documentation.
Shoppable Ads in React Native are currently supported on iOS only. Android support is planned for a future release.
PrerequisitesLien direct vers Prerequisites
- iOS 15.0+ deployment target
- @rokt/react-native-sdk 5.x
- RoktStripePaymentExtension CocoaPods pod (required for Apple Pay / Stripe payment processing)
- A Rokt account with Shoppable Ads enabled — contact your Rokt account manager
Step 1: Install dependenciesLien direct vers Step 1: Install dependencies
React NativeLien direct vers React Native
npm install @rokt/react-native-sdk --save
iOS native (Podfile)Lien direct vers iOS native (Podfile)
Add the Stripe payment extension to your ios/Podfile:
pod 'RoktStripePaymentExtension', '~> 1.0'
Then install the pods:
cd ios && pod install
Step 2: Initialize the SDKLien direct vers Step 2: Initialize the SDK
SDK initialization is the same as for standard placements. See Integrating and initializing the React Native SDK.
Step 3: Configure Apple PayLien direct vers Step 3: Configure Apple Pay
Before registering a payment extension, you need to create an Apple Pay merchant ID, configure your Xcode project, and generate a Payment Processing Certificate.
Follow the steps in Apple Pay — iOS setup, then return here to register the payment extension.
Step 4: Register a payment extensionLien direct vers Step 4: Register a payment extension
After configuring Apple Pay, register a payment extension in your native iOS code. This enables Apple Pay and Stripe payment processing within the placement.
import Rokt_Widget
import RoktStripePaymentExtension
// Register after SDK initialization, before selectShoppableAds
if let stripeExtension = RoktStripePaymentExtension(applePayMerchantId: "merchant.com.rokt.sample") {
Rokt.registerPaymentExtension(stripeExtension, config: ["stripeKey": "pk_test_placeholder"])
}
For the direct SDK path, you must provide your Stripe publishable key explicitly in the config dictionary.
You must call registerPaymentExtension after SDK initialization (Step 2) and before calling selectShoppableAds (Step 5) from your React Native code. If no payment extension is registered, selectShoppableAds will fire a PlacementFailure event.
Step 5: Display Shoppable AdsLien direct vers Step 5: Display Shoppable Ads
Shoppable Ads always display as an overlay — no embedded views or placeholders are needed.
Call selectShoppableAds from your React Native code once all required attributes are available:
import { Rokt } from '@rokt/react-native-sdk';
const attributes = {
email: 'j.smith@example.com',
firstname: 'Jane',
lastname: 'Smith',
confirmationref: 'ORD-8829-XK2',
amount: '52.25',
currency: 'USD',
paymenttype: 'visa',
shippingaddress1: '123 Main St',
shippingcity: 'Brooklyn',
shippingstate: 'NY',
shippingzipcode: '11201',
shippingcountry: 'US',
};
Rokt.selectShoppableAds('ConfirmationPage', attributes);
Step 6: Handle eventsLien direct vers Step 6: Handle events
Shoppable Ads emit the following events in addition to the standard placement events. Subscribe to events using the NativeEventEmitter mechanism:
import { RoktEventManager } from '@rokt/react-native-sdk';
import { NativeEventEmitter } from 'react-native';
const emitter = new NativeEventEmitter(RoktEventManager);
emitter.addListener('RoktEvents', (data) => {
switch (data.event) {
case 'CartItemInstantPurchaseInitiated':
console.log(`Purchase started: ${data.catalogItemId}`);
break;
case 'CartItemInstantPurchase':
console.log(`Purchase completed: ${data.catalogItemId} — ${data.totalPrice} ${data.currency}`);
break;
case 'CartItemInstantPurchaseFailure':
console.log(`Purchase failed: ${data.error}`);
break;
case 'CartItemDevicePay':
console.log(`Device payment triggered: ${data.paymentProvider}`);
break;
case 'InstantPurchaseDismissal':
console.log('User dismissed purchase');
break;
case 'PlacementClosed':
console.log('Shoppable Ads placement closed');
break;
default:
break;
}
});
Shoppable Ads eventsLien direct vers Shoppable Ads events
| Event | Description | Properties |
|---|---|---|
CartItemInstantPurchaseInitiated | Purchase flow started — user tapped "Buy" | placementId, catalogItemId, cartItemId |
CartItemInstantPurchase | Purchase completed successfully | placementId, name, cartItemId, catalogItemId, currency, description, linkedProductId, providerData, quantity, totalPrice, unitPrice |
CartItemInstantPurchaseFailure | Purchase failed | placementId, catalogItemId, cartItemId, error |
CartItemDevicePay | Apple Pay / device payment triggered | placementId, catalogItemId, cartItemId, paymentProvider |
InstantPurchaseDismissal | User dismissed the purchase overlay | placementId |
Recommended attributesLien direct vers Recommended attributes
The following attributes are particularly important for Shoppable Ads:
| Attribute | Type | Required | Description |
|---|---|---|---|
email | string | Yes | Customer email (unhashed). Used for order confirmation. |
confirmationref | string | Yes | Order or transaction reference number. |
amount | string | Recommended | Decimal transaction amount (e.g., "52.25"). |
currency | string | Recommended | ISO 4217 currency code (e.g., "USD"). |
paymenttype | string | Recommended | Payment method used for the primary purchase (e.g., "visa", "apple_pay"). Used for payment method prioritization. |
shippingaddress1 | string | Recommended | Shipping street address. |
shippingcity | string | Recommended | Shipping city. |
shippingstate | string | Recommended | Shipping state or province. |
shippingzipcode | string | Recommended | Shipping postal code. |
shippingcountry | string | Recommended | ISO Alpha-2 country code (e.g., "US"). |
For the full list of supported attributes, see the recommended attributes table.
If your platform does not have shipping address details (e.g., ticket or digital goods purchases), pass billing address details instead. Rokt will provide a UI for the customer to confirm or edit their shipping address before completing the purchase.
Payment methodsLien direct vers Payment methods
For detailed setup of individual payment methods, see:
- Apple Pay — Native Apple Pay within the Rokt placement
- Card Forwarding — Reuse the customer's vaulted card from the primary purchase