Hooking up Superwall events to 3rd party tools

SuperwallKit automatically tracks some internal events. You can view the list of events here. We encourage you to also track them in your own analytics by implementing handleSuperwallEvent(withInfo:) in your SuperwallDelegate:


You might also want to set user attribute to allow for Cohorting in 3rd Party Tools

Alternatively, if you want typed versions of all these events with associated values, you can access them via eventInfo.event:

Using events to see purchased products

If your goal is simply to view which product was purchased from a paywall, you don’t need a purchase controller for that (though it can be done in one). If you’re using a SuperwallDelegate, you can leverage the transactionComplete event, which provides direct access to the purchased product via product:

import SwiftUI 
import SuperwallKit

class SWDelegate: SuperwallDelegate {
    func handleSuperwallEvent(withInfo eventInfo: SuperwallEventInfo) {
        switch eventInfo.event {
        case .transactionComplete(let transaction, let product, let paywallInfo):
            print("Converted from paywall: \(product.productIdentifier)")
        default:
            print("\(#function) - \(eventInfo.event)")
        }
    }
}

@main
struct AwesomeApp: App {

    init() {
        Superwall.configure(apiKey: "MY_API_KEY")
        Superwall.shared.delegate = self.swDelegate
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
                .onAppear { Superwall.shared.register(event: "test_event") }
        }
    }
}

In that example, as soon as a user converts on a paywall, the product identifier will be printed to the console:

Converted from paywall: ex.someProduct.identifier