# Using the Superwall Delegate

Use Superwall's delegate to extend our SDK's functionality across several surface areas by assigning to the `delegate` property:

:::android
```kotlin
class SWDelegate : SuperwallDelegate {
    // Implement delegate methods here
}

// When configuring the SDK...
Superwall.instance.delegate = SWDelegate()
```
:::

Some common use cases for using the Superwall delegate include:

* **Custom actions:** [Respond to custom tap actions from a paywall.](/docs/sdk/guides/advanced/custom-paywall-actions#custom-paywall-actions)
* **Respond to purchases:** [See which product was purchased from the presented paywall.](/docs/sdk/guides/advanced/viewing-purchased-products)
* **Analytics:** [Forward events from Superwall to your own analytics.](/docs/sdk/guides/3rd-party-analytics)

Below are some commonly used implementations when using the delegate.

Superwall Events [#superwall-events]

Most of what occurs in Superwall can be viewed using the delegate method to respond to events:

:::android
```kotlin
class SWDelegate : SuperwallDelegate {
  override fun handleSuperwallEvent(eventInfo: SuperwallEventInfo) {
    // Handle any relevant events here...
    when (eventInfo.event) {
        is SuperwallPlacement.TransactionComplete -> {
          val transaction = (eventInfo.event as SuperwallPlacement.TransactionComplete).transaction
          val product = (eventInfo.event as SuperwallPlacement.TransactionComplete).product
          val paywallInfo = (eventInfo.event as SuperwallPlacement.TransactionComplete).paywallInfo
          println("Transaction Complete: $transaction, Product: $product, Paywall Info: $paywallInfo")
        }
        else -> {
          // Handle other cases
        }
    }
  }
}
```
:::

Paywall Custom Actions [#paywall-custom-actions]

Using the [custom tap action](/docs/sdk/guides/advanced/custom-paywall-actions#custom-paywall-actions), you can respond to any arbitrary event from a paywall:

:::android
```kotlin
class SWDelegate : SuperwallDelegate {
  override fun handleCustomPaywallAction(withName: String) {
    if (withName == "caffeineLogged") {
      println("Custom paywall action: $withName")
    }
  }
}
```
:::

Subscription status changes [#subscription-status-changes]

You can be informed of subscription status changes using the delegate. If you need to set or handle the status on your own, use a [purchase controller](/docs/sdk/guides/advanced-configuration) — this function is only for informational, tracking or similar purposes:

:::android
```kotlin
class SWDelegate : SuperwallDelegate {
  override fun subscriptionStatusDidChange(from: SubscriptionStatus, to: SubscriptionStatus) {
    println("Subscription status changed from $from to $to")
  }
}
```
:::

Paywall events [#paywall-events]

The delegate also has callbacks for several paywall events, such dismissing, presenting, and more. Here's an example:

:::android
```kotlin
class SWDelegate : SuperwallDelegate {
  override fun didPresentPaywall(withInfo: PaywallInfo) {
    println("Paywall presented: $withInfo")
  }
}
```
:::