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.

Create a new sessionAnchorIcon

  1. Swift
let shopperInsightsClient = BTShopperInsightsClientV2(authorization: "<CLIENT_AUTHORIZATION>")

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
}

Update an existing customer sessionAnchorIcon

  1. Swift
let shopperInsightsClient = BTShopperInsightsClient(
    authorization: "<CLIENT_AUTHORIZATION>", 
    shopperSessionID: "<SHOPPER_SESSION_ID>"
)

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
}

Generate customer recommendationsAnchorIcon

Customers are recommended PayPal or Venmo payment options.
  1. Swift
let shopperInsightsClient = BTShopperInsightsClientV2(authorization: "<CLIENT_AUTHORIZATION>")

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
}

AnalyticsAnchorIcon

Call `sendPresentedEvents`, followed by `sendSelectedEvent` when the PayPal or Venmo button has been displayed to or selected/tapped by the buyer, respectively. These methods sends analytics to help improve the Shopper Insights feature experience. The `buttonType` object is the type of button presented - PayPal, Venmo, or Other.
  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)