Skip to content

Analytics

Get actionable, trackable data instantly to drive better decisions and performance.

Overview

Analytics events are structured data objects that are automatically triggered when significant actions or states occur within the drop-in. These allow you to monitor every aspect of the payment journey across cards, PayPal, Apple Pay, Aeropay, and other enabled payment methods.

Analytics events allow you to:

  • Gain transparency with native transaction tracking in PXP reports.
  • Optimise conversion rates and reduce drop-offs, thanks to actionable insights.
  • Feed real-time data into your analytics and CRM systems.

DeviceType is emitted during CheckoutDropIn(config:) initialisation. Most component, payment lifecycle, and Aeropay journey events require await create() and a mounted buildContent() view.

Consume an event

Analytics events should be consumed in the analyticsEvent callback when initialising Drop-in.

Basic example

The following example wires analyticsEvent on CheckoutDropInConfig, then creates and mounts Drop-in so component and Aeropay flow analytics can fire:

import PXPCheckoutSDK

let config = CheckoutDropInConfig(
    environment: .test,
    session: sessionData,
    transactionData: DropInTransactionData(
        amount: Decimal(string: "99.99") ?? 0,
        currency: "USD",
        entryType: .ecom,
        intent: DropInTransactionIntentData(
            card: .authorisation,
            paypal: .authorisation
        ),
        merchantTransactionId: UUID().uuidString,
        merchantTransactionDate: { Date() }
    ),
    merchantShopperId: "shopper-001",
    ownerId: "MERCHANT_GROUP_1", // Merchant group ID (ownerType is always "MerchantGroup")
    onGetShopper: { async in
        TransactionShopper(id: "shopper-001")
    },
    analyticsEvent: { event in
        print("Analytics event: \(event.eventName)")
        
        // Send to your analytics platform
        sendToAnalyticsPlatform(event)
    },
    onSuccess: { result in
        verifyPaymentOnBackend(result)
    },
    onError: { paymentMethod, error in
        print("Payment failed: \(error.errorMessage)")
    }
)

let checkoutDropIn = try CheckoutDropIn(config: config)
await checkoutDropIn.create()
// In SwiftUI: checkoutDropIn.buildContent()

Component and Aeropay flow analytics fire after create() wires components and the Drop-in UI is mounted. DeviceType is the only event from config and CheckoutDropIn initialisation alone.

Typed event handling

Since event-specific fields live on subclasses, cast to the concrete type for typed access:

analyticsEvent: { event in
    switch event {
    case let componentEvent as ComponentInteractionAnalyticsEvent:
        print("Component interaction:")
        print("- Type: \(componentEvent.componentType)")
        print("- Interaction: \(componentEvent.interactionType.rawValue)")
        print("- ID: \(componentEvent.componentId)")
        
    case let errorEvent as ComponentErrorAnalyticsEvent:
        print("Component error:")
        print("- Code: \(errorEvent.errorCode ?? "unknown")")
        print("- Message: \(errorEvent.errorMessage)")
        print("- Component ID: \(errorEvent.componentId)")
        
    case let lifecycleEvent as ComponentLifecycleAnalyticsEvent:
        print("Component lifecycle:")
        print("- Event: \(lifecycleEvent.eventType.rawValue)")
        print("- Component ID: \(lifecycleEvent.componentId)")
        
    default:
        print("Analytics event: \(event.eventName)")
    }
    
    // Encode and send to analytics platform
    do {
        let encoder = JSONEncoder()
        encoder.dateEncodingStrategy = .iso8601
        let data = try encoder.encode(event)
        sendToAnalyticsPlatform(data)
    } catch {
        print("Failed to encode analytics event: \(error)")
    }
}

Event structure

All analytics events inherit from BaseAnalyticsEvent and contain the following base properties:

Property Description
eventName
String
The name of the analytics event (e.g., "ComponentInteraction", "ApplePaySheetOpened").
sessionId
String
The session ID for the current checkout session.
timestamp
Date
When the event occurred (Swift Date type).

Event-specific fields are encoded as top-level properties on each subclass, not under a nested properties object. For example, ComponentInteractionAnalyticsEvent adds componentType, interactionType, and componentId as top-level fields.

Serialising events

When sending events to external analytics platforms, you'll typically need to encode them to JSON:

analyticsEvent: { event in
    do {
        let encoder = JSONEncoder()
        encoder.dateEncodingStrategy = .iso8601
        let data = try encoder.encode(event)
        
        // Send encoded data to analytics platform
        sendToAnalyticsPlatform(data)
    } catch {
        print("Failed to encode analytics event: \(error)")
    }
}

Set dateEncodingStrategy = .iso8601 (or your platform's preferred strategy). The default JSONEncoder doesn't produce ISO 8601 strings for Date; without a strategy, dates encode as floating-point reference dates.

iOS SDK analytics events

The iOS SDK emits structured analytics events through several event classes. Each event inherits from BaseAnalyticsEvent and adds event-specific fields.

Drop-in construction events

The following table lists events emitted when you construct Drop-in:

Event name Swift class Description
DeviceTypeDeviceTypeAnalyticsEventFired during CheckoutDropIn(config:) initialisation via triggerAnalyticsEvents(), before await create() and before any payment panel (including Aeropay) is visible. Includes deviceType.

Most component interaction, lifecycle, payment method, and Aeropay journey events require await create() and a mounted buildContent() view.

Component lifecycle events

The following table lists component lifecycle events:

Event name Swift class Description
ComponentLifecycleEventComponentLifecycleAnalyticsEventFired when a component mounts or unmounts. Includes eventType and componentId. Most drop-in components use .mount / .unmount (JSON: "Mount", "Unmount"). The SDK also defines Loaded, Unloaded, Callback, and onMounted for other components.

Component interaction events

The following table lists component interaction events:

Event name Swift class Description
ComponentInteractionComponentInteractionAnalyticsEventFired when a user interacts with a component. Includes componentType, interactionType, and componentId. Swift cases are .focus, .blur, .change, .submit, .paste, .click, and .close; JSON encodes PascalCase raw values ("Focus", "Blur", "Change", "Submit", "Paste", "Click", "Close").

Component error events

The following table lists component error events:

Event name Swift class Description
ComponentErrorComponentErrorAnalyticsEventFired when a component error occurs. Includes errorCode, errorMessage, and componentId.
ErrorMessageShownMessageShownAnalyticsEventFired when an error or validation message is displayed to the user. Includes componentType, messageContent, and componentId.

Payment lifecycle events

The following table lists shared payment lifecycle events. Each row shows the eventName string and its Swift class:

Event name Swift class Description
ComponentAbandonmentComponentAbandonmentAnalyticsEventFired when a payment component is abandoned. Includes componentType.
PaymentAbandonmentPaymentAbandonmentAnalyticsEventFired when a payment flow is abandoned. Includes componentType.
PreTokenizationPreTokenizationAnalyticsEventFired before card tokenisation begins. Includes componentType and transactionId.
PostTokenizationPostTokenizationAnalyticsEventFired after card tokenisation completes. Includes componentType and transactionId.
PreInitiateAuthenticationPreInitiateAuthenticationAnalyticsEventFired before 3D Secure authentication is initiated. Includes componentType and transactionId.
PostInitiateAuthenticationPostInitiateAuthenticationAnalyticsEventFired after 3D Secure authentication is initiated. Includes componentType and transactionId.
PreAuthenticationPreAuthenticationAnalyticsEventFired before 3D Secure authentication begins. Includes componentType and transactionId.
PostAuthenticationPostAuthenticationAnalyticsEventFired after 3D Secure authentication completes. Includes componentType and transactionId.
PreAuthorisationPreAuthorisationAnalyticsEventFired before payment authorisation begins when the component's onPreAuthorisation callback is set. Includes componentType, transactionId, and isRetry (Bool, default false). Drop-in emits this for card, Apple Pay, and Aeropay (and card-on-file when enabled). PayPal doesn't use these events.
PostAuthorisationPostAuthorisationAnalyticsEventFired after the authorisation HTTP response is processed when the component's onPostAuthorisation callback is set. Includes componentType, transactionId, and isRetry (Bool, default false). Drop-in emits this for card, Apple Pay, and Aeropay (and card-on-file when enabled). PayPal doesn't use these events.

Drop-in emits PreAuthorisation / PostAuthorisation for card, Apple Pay, and Aeropay when the component callbacks are wired. PayPal doesn't use these events.

Apple Pay events

Apple Pay emits several specific analytics events:

Event name Description
ApplePayButtonClickFired when the customer taps the Apple Pay button.
ApplePaySheetOpenedFired when the Apple Pay payment sheet opens.
ApplePaySheetCompletedFired when the customer completes the Apple Pay payment sheet.
ApplePayFlowCancelledFired when the customer cancels the Apple Pay flow.
ApplePayRetryAttemptFired when a retry is attempted after an Apple Pay failure.
ApplePayBlobDecryptionFailedFired when Apple Pay payment data decryption fails.
ApplePayPaymentRequestCreationFailedFired when Apple Pay payment request creation fails.

Apple Pay events extend ApplePayAnalyticsEvent and include walletType (always "ApplePay"), componentId, merchantTransactionId, optional customerID, and optional additionalData.

PayPal events

PayPal emits retry analytics events:

Event name Description
PayPalRetryAttemptFired when a retry is attempted after a PayPal failure. Includes componentId, merchantTransactionId, optional customerID, and retry count in additionalData.

PayPal validation failures and errors are emitted through ComponentErrorAnalyticsEvent with PayPal-specific error codes and messages.

PayPal authorisation is tracked via PayPalRetryAttempt and ComponentError, not PreAuthorisation / PostAuthorisation.

Aeropay events

Aeropay analytics are delivered through the same analyticsEvent handler on CheckoutDropInConfig as other Drop-in methods. There are no Drop-in-only Aeropay event names.

Aerosync and authorisation

Event name Description
AerosyncLaunchedFired when the Aerosync bank-linking widget opens. Typical fields: eventName, sessionId, timestamp, componentId.
AerosyncCompletedFired when Aerosync bank linking completes successfully. Typical fields: eventName, sessionId, timestamp, componentId.
AerosyncFailedFired when Aerosync bank linking fails. Typical fields: eventName, sessionId, timestamp, componentId.
PreAuthorisationEmitted when Drop-in's internal onPreAuthorisation hook is configured, before the callback runs. Merchant onSubmit(.aeropay) fires during that callback, not before the analytics event. Order: PreAuthorisation analytics → onPreAuthorisation / onSubmit → Unity processTransaction. The event can still fire if later logic inside the callback path does not complete a successful submit; Drop-in always proceeds after onSubmit for Aeropay. Fields: eventName, sessionId, timestamp, componentType (aeropay), transactionId (your merchantTransactionId), isRetry (Bool, default false).
PostAuthorisationFired after Aeropay Unity transaction authorisation completes successfully. Drop-in also calls merchant onSuccess for successful submissions. Fields: eventName, sessionId, timestamp, componentType (aeropay), transactionId, isRetry (Bool, default false).

Interaction, lifecycle, and errors

Event name Description
ComponentInteractionShopper activity such as button taps and popup close actions. Includes componentType, interactionType (for example Click, Close, Submit), and componentId. For the Pay by bank button, Click is emitted only after onBeforeSubmit returns true (when that callback is configured).
ComponentLifecycleEventPopup screen mount and unmount activity.
ComponentErrorSDK or provider failures during the Aeropay flow. Includes errorCode, errorMessage, and optional componentId. Mapped failed Unity transaction responses can emit SDK1326 on this analytics event (AeropayPaymentFailedException). Merchant onError typically receives the API failure code from FailedSubmitResult when present, or SDK1126, not SDK1326. There's no separate merchant onSubmitError in Drop-in.
ErrorMessageShownA message was shown in the Aeropay UI (field validation, OTP, bank linking, or transaction feedback). Not emitted merely because an error occurred.
ApplePayRetryAttemptShared Unity retry signal that can also fire on the Aeropay path. Treat the name as a shared retry event, not as Apple Pay-only. Includes sessionId, componentId, merchantTransactionId, walletType (always ApplePay on this event type), and additionalData.retryCount.

Aeropay uses these componentType values to identify parts of the flow:

Component typeArea
aeropay-buttonMain Aeropay payment button in the Drop-in panel
aeropayDataCollectionConsumer data collection screen
aeropayOtpVerificationOTP verification screen
aeropayAerosyncBank selection and Aerosync screen

Don't use analytics events to confirm Aeropay payments. Verify the transaction on your backend using webhooks or the Get transaction details API.