Get actionable, trackable data instantly to drive better decisions and performance.
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.
Analytics events should be consumed in the analyticsEvent callback when initialising Drop-in.
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.
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)")
}
}All analytics events inherit from BaseAnalyticsEvent and contain the following base properties:
| Property | Description |
|---|---|
eventNameString | The name of the analytics event (e.g., "ComponentInteraction", "ApplePaySheetOpened"). |
sessionIdString | The session ID for the current checkout session. |
timestampDate | 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.
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.
The iOS SDK emits structured analytics events through several event classes. Each event inherits from BaseAnalyticsEvent and adds event-specific fields.
The following table lists events emitted when you construct Drop-in:
| Event name | Swift class | Description |
|---|---|---|
DeviceType | DeviceTypeAnalyticsEvent | Fired 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.
The following table lists component lifecycle events:
| Event name | Swift class | Description |
|---|---|---|
ComponentLifecycleEvent | ComponentLifecycleAnalyticsEvent | Fired 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. |
The following table lists component interaction events:
| Event name | Swift class | Description |
|---|---|---|
ComponentInteraction | ComponentInteractionAnalyticsEvent | Fired 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"). |
The following table lists component error events:
| Event name | Swift class | Description |
|---|---|---|
ComponentError | ComponentErrorAnalyticsEvent | Fired when a component error occurs. Includes errorCode, errorMessage, and componentId. |
ErrorMessageShown | MessageShownAnalyticsEvent | Fired when an error or validation message is displayed to the user. Includes componentType, messageContent, and componentId. |
The following table lists shared payment lifecycle events. Each row shows the eventName string and its Swift class:
| Event name | Swift class | Description |
|---|---|---|
ComponentAbandonment | ComponentAbandonmentAnalyticsEvent | Fired when a payment component is abandoned. Includes componentType. |
PaymentAbandonment | PaymentAbandonmentAnalyticsEvent | Fired when a payment flow is abandoned. Includes componentType. |
PreTokenization | PreTokenizationAnalyticsEvent | Fired before card tokenisation begins. Includes componentType and transactionId. |
PostTokenization | PostTokenizationAnalyticsEvent | Fired after card tokenisation completes. Includes componentType and transactionId. |
PreInitiateAuthentication | PreInitiateAuthenticationAnalyticsEvent | Fired before 3D Secure authentication is initiated. Includes componentType and transactionId. |
PostInitiateAuthentication | PostInitiateAuthenticationAnalyticsEvent | Fired after 3D Secure authentication is initiated. Includes componentType and transactionId. |
PreAuthentication | PreAuthenticationAnalyticsEvent | Fired before 3D Secure authentication begins. Includes componentType and transactionId. |
PostAuthentication | PostAuthenticationAnalyticsEvent | Fired after 3D Secure authentication completes. Includes componentType and transactionId. |
PreAuthorisation | PreAuthorisationAnalyticsEvent | Fired 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. |
PostAuthorisation | PostAuthorisationAnalyticsEvent | Fired 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 emits several specific analytics events:
| Event name | Description |
|---|---|
ApplePayButtonClick | Fired when the customer taps the Apple Pay button. |
ApplePaySheetOpened | Fired when the Apple Pay payment sheet opens. |
ApplePaySheetCompleted | Fired when the customer completes the Apple Pay payment sheet. |
ApplePayFlowCancelled | Fired when the customer cancels the Apple Pay flow. |
ApplePayRetryAttempt | Fired when a retry is attempted after an Apple Pay failure. |
ApplePayBlobDecryptionFailed | Fired when Apple Pay payment data decryption fails. |
ApplePayPaymentRequestCreationFailed | Fired 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 emits retry analytics events:
| Event name | Description |
|---|---|
PayPalRetryAttempt | Fired 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 analytics are delivered through the same analyticsEvent handler on CheckoutDropInConfig as other Drop-in methods. There are no Drop-in-only Aeropay event names.
| Event name | Description |
|---|---|
AerosyncLaunched | Fired when the Aerosync bank-linking widget opens. Typical fields: eventName, sessionId, timestamp, componentId. |
AerosyncCompleted | Fired when Aerosync bank linking completes successfully. Typical fields: eventName, sessionId, timestamp, componentId. |
AerosyncFailed | Fired when Aerosync bank linking fails. Typical fields: eventName, sessionId, timestamp, componentId. |
PreAuthorisation | Emitted 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). |
PostAuthorisation | Fired 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). |
| Event name | Description |
|---|---|
ComponentInteraction | Shopper 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). |
ComponentLifecycleEvent | Popup screen mount and unmount activity. |
ComponentError | SDK 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. |
ErrorMessageShown | A message was shown in the Aeropay UI (field validation, OTP, bank linking, or transaction feedback). Not emitted merely because an error occurred. |
ApplePayRetryAttempt | Shared 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 type | Area |
|---|---|
aeropay-button | Main Aeropay payment button in the Drop-in panel |
aeropayDataCollection | Consumer data collection screen |
aeropayOtpVerification | OTP verification screen |
aeropayAerosync | Bank 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.