Shopper Insights (Beta)

OverviewAnchorIcon

Use Shopper Insights to optimize your checkout experience by prioritizing the customer’s preferred payment methods in your UI. Customizing the checkout experience can improve conversion, increase repeat buys and boost user retention.

IntegrationAnchorIcon

The generateCustomerRecommendations method returns PayPal or Venmo as recommended payment using their email.

Before using this method, obtain consent from the customer to share this information with PayPal services.

Use the following code snippet to get the recommended payment methods and adjust your UI/UX accordingly.
  1. Swift
let apiClient = BTAPIClient(authorization: “CLIENT_TOKEN”)
let shopperInsightsClient = BTShopperInsightsClientV2(apiClient: apiClient)

let request = BTCustomerSessionRequest(
    hashedEmail: sha256Hash(emailView.textField.text ?? ""),
    hashedPhoneNumber: sha256Hash(nationalNumberView.textField.text ?? "")
)

do {
    let sessionID = try await shopperInsightsClient.createCustomerSession(request: request)
    // handle success
} catch {
    // handle error
}
  1. Swift
let apiClient = BTAPIClient(authorization: “CLIENT_TOKEN”)
let shopperInsightsClient = BTShopperInsightsClientV2(apiClient: apiClient)

let request = BTCustomerSessionRequest(
    hashedEmail: sha256Hash(emailView.textField.text ?? ""),
    hashedPhoneNumber: sha256Hash(nationalNumberView.textField.text ?? "")
)
let sessionID = "[SESSION-ID]"

do {
    let sessionID = try await shopperInsightsClient.updateCustomerSession(
        request: request,
        sessionID: sessionID
    )
    // handle success
} catch {
    // handle error
}
  1. Swift
let apiClient = BTAPIClient(authorization: “CLIENT_TOKEN”)
let shopperInsightsClient = BTShopperInsightsClientV2(apiClient: apiClient)

let request = BTCustomerSessionRequest(
    hashedEmail: sha256Hash(emailView.textField.text ?? ""),
    hashedPhoneNumber: sha256Hash(nationalNumberView.textField.text ?? "")
)
let sessionID = "[SESSION-ID]"

do {
    let result = try await shopperInsightsClient.generateCustomerRecommendations(
        request: request,
        sessionID: sessionID
    )
    
    if let recommendations = result.paymentRecommendations {
        if recommendations.contains(where: { $0.paymentOption.uppercased() == "PAYPAL" }) {
            // PayPal was recommended
        }

        if recommendations.contains(where: { $0.paymentOption.uppercased() == "VENMO" }) {
            // Venmo was recommended
        }
    }
} catch {
    // handle error
}
  1. Swift
// Send after presenting recommendations
let presentmentDetails = BTPresentmentDetails(
    buttonOrder: mapPriorityToButtonOrder(payPalOption.recommendedPriority),
    experimentType: .control,
    pageType: .about
)

shopperInsightsClient.sendPresentedEvent(
    for: .payPal,
    presentmentDetails: presentmentDetails,
    sessionID: sessionID
)

// Send after the user has selected an option
shopperInsightsClient.sendSelectedEvent(for: .payPal, sessionID: sessionID)