Tracking Events

By tracking analytical events with Superwall, you can retroactively decide when and where to show a paywall in your app.

Take the following event as an example:

Paywall.track(
  "workout_complete", 
  ["total_workouts": 17]
)

You can configure a rule via the dashboard to show a paywall every time this event gets tracked. Superwall caches your events and rules on app launch, so the instant this event gets tracked, a paywall will be presented to the user if you have a rule set up to do so.

For your convenience, some events are automatically tracked by the SDK. Specifically: app_install, app_launch, and session_start.

To provide your team with ultimate flexibility, we recommend sending all your analytical events to Superwall via Paywall.track(_:_:). This way you can retroactively add a paywall to any of your analytical events, should you decide to do so (without an app update!)

If you're already set up with an analytics provider, you'll typically have an Analytics.swift singleton (or similar) to disperse all your events from. Here's how that file might look:

import Paywall
import Mixpanel
import Firebase

final class Analytics {
  static var shared = Analytics()
  
  func track(
    event: String,
    properties: [String: Any]
  ) {
    // Superwall
    Paywall.track(event, properties)
    
    // Firebase (just an example)
    Firebase.Analytics.logEvent(event, parameters: properties)
    
    // Mixpanel (just an example)
    Mixpanel.mainInstance().track(event: eventName, properties: properties)
  }
}
  
  
// And thus ...
  
Analytics.shared.track(
  "workout_complete",
  ["total_workouts": 17]
)
  
// ... just works :)

In many scenarios, you may need callbacks to take appropriate actions when a user converts or skips your paywall. Triggering a paywall explicitly gives you this functionality.


Did this page help you?