Prerequisites
Before you get started, make sure you have the following:- Obtain your publishable key (
DUB_PUBLISHABLE_KEY) from your workspace’s Tracking settings page. - You would also want to have your custom domain (
DUB_DOMAIN) handy as well. - (Optional) If you plan to track conversions, make sure to enable conversion tracking for your links.
Quickstart
This quick start guide will show you how to get started with Dub iOS SDK in your Swift project.1
Install the Dub iOS SDK
Before installing, ensure your environment meets these minimum requirements:Build Tools:
- Xcode 16+
- Swift 4.0+
- iOS 16.0+
- macOS 10.13 (Ventura)+
https://github.com/dubinc/dub-ios as the repository URL. Select the latest version of the SDK from the release page.2
Initialize the SDK
You must call
Dub.setup with your publishable key and domain prior to being able to use the dub instance.Track deep link open events
Call
trackOpen on the dub instance to track deep link and deferred deep link open events.
The trackOpen function should be called once without a deepLink parameter on first launch, and then
again with the deepLink parameter whenever the app is opened from a deep link.4
Track lead events (optional)
To track lead events, call
trackLead on the dub instance with your customer’s external ID, name, and email.Lead event attributes
Lead event attributes
Here are the properties you can include when sending a lead event:
5
Track sale events (optional)
To track sale events, call
trackSale on the dub instance with your customer’s user ID and purchase information.Sale event attributes
Sale event attributes
Here are the properties you can include when sending a sale event:
Examples
Here are some open-source code examples that you can reference:Swift (SwiftUI)
See the full example on GitHub.
Swift (UIKit)
See the full example on GitHub.