Custom Paywall Actions

Custom Paywall.js Events

The Paywall SDK automatically recognizes elements on the paywall tagged with data tags. For example, elements tagged with data-pw-restore, data-pw-close and data-pw-purchase are recognised as restore, close, and purchase buttons respectively. The SDK links taps on these elements to corresponding logic in either the SDK or in Paywall's delegate.

However, the SDK also lets you add your own custom identifiers to buttons, allowing you to tie any button tap in your paywall to real hard-coded application scoped logic.

For example, simply adding data-pw-custom="help_center" to a button in your HTML paywall gives you the opportunity to present a help center whenever that button is pressed. To set this up, implement the handleCustomPaywallAction(withName:) in your PaywallDelegate:

extension PaywallService: PaywallDelegate {
  func handleCustomPaywallAction(withName name: String) {
    if name == "help_center" {
      HelpCenterManager.present()
    }
  }
}
// Inside PaywallService.m

- (void)handleCustomPaywallActionWithName:(NSString *)name
{
    NSLog(@"Custom button: %@", name);
}

Did this page help you?