Developer GuideMobile apps
Swift SDK
Add Venbit.swift to an iOS app, call Venbit.start once at launch, and report sign-ups and trials. Every public function, with examples.
The Swift SDK is a single file, Venbit.swift. Drag it into your Xcode project and call Venbit.start once at launch. After that the app reports its install, a daily "opened today" note, and every StoreKit purchase, renewal and refund. You won't need a package manager or a permission prompt.
Venbit.start(appKey: "vba_YOUR_APP_KEY")Your real key is on the app's Install tab in the dashboard, already inside the line to copy. If you haven't added the app yet, see App tracking overview.
Add the file
- Download Venbit.swift, or use Download Venbit.swift on the Install tab.
- Drag it into your Xcode project and make sure your app target is ticked.
You're done installing. There's no Swift package or pod to add. The file imports only Foundation, Security and StoreKit, and since it sits in your own target you call Venbit without an import.
No minimum iOS version is set in the file. Purchase reporting uses StoreKit 2, which means iOS 15 and later; on older systems purchases are skipped and everything else still works.
Call start at launch
Call it once, as early in launch as you like. It never blocks. Running it on every launch is safe too, because once the install has been reported it won't be reported again.
In a SwiftUI app, use the App struct's init:
import SwiftUI
@main
struct HarborRoofingApp: App {
init() {
Venbit.start(appKey: "vba_YOUR_APP_KEY")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}In a UIKit app, use the app delegate:
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Venbit.start(appKey: "vba_YOUR_APP_KEY")
return true
}
}Don't call it from a view's onAppear. And don't bother hiding the key in a config file or a secret store: it only names which app is reporting, and it's meant to ship inside the binary.
If a coding agent works in your Xcode project, give it this:
Add Venbit install tracking to this iOS app. Download https://venbit.com/sdk/Venbit.swift into the app target (there is no Swift package or pod, and no import is needed). Call Venbit.start(appKey: "[your vba_ key]") once at launch: in the SwiftUI App struct's init, or in application(_:didFinishLaunchingWithOptions:). Not in onAppear. Add Venbit.event("signup") on the line right after an account is created, not on sign-in. Add no purchase code (StoreKit is reported automatically) and no tracking permission prompt.Venbit.start
static func start(
appKey: String,
endpoint: String = "https://venbit.com",
watchPurchases: Bool = true,
onAttribution: (@Sendable (Venbit.Attribution) -> Void)? = nil
)| Parameter | What it does |
|---|---|
appKey | Your app key, starting vba_. |
endpoint | Where reports are sent. Leave the default. |
watchPurchases | true reports StoreKit purchases, renewals and refunds for you. Pass false to send your own with Venbit.event. |
onAttribution | Optional. Called once on the main queue, after the first launch has been reported, with what's known about where the install came from. |
Open a screen after install
A smart link can name a screen inside your app (the Opens field when you make the link). On first launch, onAttribution hands it to you so you can take the new user there.
Venbit.start(appKey: "vba_YOUR_APP_KEY") { result in
if let path = result.deepLink {
// e.g. "/estimates/new". Route to it with your own navigation.
NotificationCenter.default.post(name: .init("OpenPath"), object: path)
}
}Venbit.Attribution has three properties:
| Property | Type | Meaning |
|---|---|---|
campaign | String? | The name of the smart link that was tapped, if the install was matched to one. |
deepLink | String? | The screen that link asked to open, if it named one. |
confidence | String | "high", "likely" or "none". "none" means the install wasn't matched to a link. |
The callback fires only when the install is first reported. Later launches don't trigger it. Nor does a first report that couldn't reach Venbit (that one's retried on the next launch).
To wire the deep link into your own navigation:
In this iOS app, pass an onAttribution closure to the existing Venbit.start call. When result.deepLink is set (a path such as "/estimates/new" from a Venbit smart link), route the new user to that screen with the app's existing navigation. Ignore it when deepLink is nil. The closure runs once, on the main queue, after the first launch is reported.Venbit.event
static func event(
_ kind: String,
valueCents: Int? = nil,
currency: String? = nil,
meta: [String: String]? = nil
)Call this when something worth counting happens. Use short lower_snake_case names, and only for things your app really has.
// Right after an account is created. Not on sign-in.
Venbit.event("signup")
// When a free trial begins
Venbit.event("trial_started")
// Anything else of your own
Venbit.event("estimate_requested")Get signup right, since the dashboard's sign-up count is built from it. Put it on the line after the account exists.
Purchases don't need an event call. With watchPurchases on (the default), the file reports them from StoreKit under these names:
| Name | When |
|---|---|
purchase | The first paid transaction, including the first charge after a free trial. |
renewal | A later charge on the same subscription. |
trial_started | A free trial begins. |
refund | A purchase is refunded. Sent as a negative amount so the campaign's total comes back down. |
They carry the product id plus the real price and currency from StoreKit. Purchases shared through Family Sharing are skipped. So are purchases made before this install existed, like restores or a subscription bought on another device.
Turn watchPurchases off and you send your own. valueCents is the price times 100, so $49.99 is 4999. Put the store's transaction id in meta and the same purchase arriving twice is counted once.
Venbit.start(appKey: "vba_YOUR_APP_KEY", watchPurchases: false)
// Later, where a purchase completes:
Venbit.event(
"purchase",
valueCents: 4999,
currency: "USD",
meta: ["product": "pro_yearly", "txn": "2000000123456789"]
)If you send an event before start has run in this launch, it's still delivered, provided start ran on an earlier launch.
Venbit.installId
static var installId: String { get }This is the random id the install reports under. Handy for lining Venbit's numbers up with your own records.
print("Venbit install:", Venbit.installId)Venbit.resetForTesting
static func resetForTesting()Forgets everything, so the next launch behaves like a brand new install. You'll want it while testing. The install is reported once and remembered in the keychain, so a second test run correctly does nothing, and deleting the app doesn't clear the keychain.
#if DEBUG
Button("Reset Venbit install") {
Venbit.resetForTesting()
}
#endifTap it, relaunch the app, and you get a fresh install report. Never ship it where a real user can reach it, or they'll be counted twice.
What the SDK sends and when
Every request is an HTTPS POST to https://venbit.com with a 10 second timeout. Failed requests aren't queued on the device. The install report and the daily note get tried again the next time the app opens.
| When | What's sent |
|---|---|
| First launch after install, once | App key, the random install id, device model (such as iPhone16,2), OS version, bundle id. |
| At most once a day, on launch or on returning to the foreground | App key, install id, app version, OS version. Days are UTC. |
Each Venbit.event call | App key, install id, the event name, a random event id, and the amount, currency and meta you passed. |
| Each StoreKit purchase, renewal or refund | The same as an event, with the product id and transaction id. |
Debug builds, simulator runs and TestFlight builds mark what they send as test launches, and the dashboard tells you how many installs have arrived marked that way.
The SDK never sends the advertising identifier, the vendor identifier, a name, an email address, contacts, location, or anything about other apps.
Privacy prompts
You don't need a permission prompt or an App Tracking Transparency request. The SDK never reads the advertising identifier, so there's no reason to add a tracking usage description for it.
On the device it keeps its install id and a few markers in the keychain (under the service com.venbit.attribution) and the date of the last daily note in UserDefaults.
Test your integration
- Run the app from Xcode with
Venbit.startin place. - Open the app's Overview in the dashboard. Within about a minute Waiting for the first report is replaced by the app's numbers.
- To run the first-launch path again, call
Venbit.resetForTesting()and relaunch.
If nothing shows up, check that the key in your code matches the one on the Install tab, and that the device had a network connection on first launch.
Common questions
Is there a Swift package or CocoaPod for Venbit?
No. The Venbit Swift SDK is a single file, Venbit.swift, that you drag into your Xcode target. It imports only Foundation, Security and StoreKit, and you call Venbit without an import.
Do I need to report in-app purchases to Venbit myself?
Not with the Swift SDK. With watchPurchases on (the default), it reports StoreKit purchases, renewals, trial starts and refunds with their real price and currency. Only pass watchPurchases: false if you'd rather send your own with Venbit.event.
Why doesn't Venbit report my test install a second time?
The install is reported once and remembered in the keychain, and deleting the app doesn't clear it. Call Venbit.resetForTesting() from a debug-only button and relaunch to run the first-launch path again.
Do TestFlight installs count in my Venbit numbers?
Debug builds, simulator runs and TestFlight builds mark what they send as test launches, and the dashboard tells you how many installs arrived marked that way.
Last updated . Something wrong or missing on this page? Tell us from Settings, then Support.

