The ASO Project / Guides

    Tap Attribution SDK - iOS Integration Guide

    Install and configure the Tap Attribution SDK for iOS, with Swift examples for attribution, purchases, revenue, custom events and user opt-outs.

    The ASO Project dashboard
    The ASO Project dashboard

    What the SDK does

    The Tap Attribution SDK connects your app's installs and revenue to the Apple Ads campaigns that drove them, with everything reported into client dashboard by The ASO Project. Once integrated, it automatically:

    • Reports installs - on first launch it securely captures Apple's attribution token, which lets us match the install to the campaign, ad group, and keyword that produced it.
    • Tracks purchases and subscriptions - verified StoreKit 2 transactions (including renewals and family purchases) are reported as revenue, with duplicates filtered automatically.
    • Delivers your custom events - trials started, onboarding completed, leads qualified - anything you want measured against campaign performance.

    Events are stored on-device and delivered in batches, so nothing is lost if the user is offline or the app is terminated.

    Privacy-friendly by design

    The SDK does not collect the IDFA and does not require the App Tracking Transparency prompt. Apple's attribution token works without any user-facing permission dialog.

    Requirements

    • iOS 15.0 or later
    • Xcode 15+ / Swift 5.9+
    • Your Tap SDK API key - found in your client dashboard account settings, or ask your account manager if you don't have one yet

    Installation

    The SDK is distributed via Swift Package Manager.

    1. In Xcode, choose File → Add Package Dependencies…
    2. Enter the package URL: https://github.com/The-ASO-Project/TapAttributionSDK.git
    3. Select Up to Next Major Version from 1.0.0 and add the TapAttributionSDK library to your app target.

    Or, if you manage dependencies in Package.swift:

    dependencies: [
        .package(url: "https://github.com/The-ASO-Project/TapAttributionSDK.git", from: "1.0.0")
    ]

    Initialize the SDK

    Start the SDK as early as possible in your app's launch so the install event is captured on the user's very first session.

    SwiftUI

    import TapAttributionSDK
    
    @main
    struct MyApp: App {
        init() {
            TapAttribution.start(with: TapConfiguration(
                apiKey: "YOUR_SDK_API_KEY"
            ))
        }
        var body: some Scene { WindowGroup { ContentView() } }
    }

    UIKit

    import TapAttributionSDK
    
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        TapAttribution.start(with: TapConfiguration(apiKey: "YOUR_SDK_API_KEY"))
        return true
    }

    That's it for attribution - on the first launch after install, the SDK captures the Apple Ads attribution token and reports the install automatically. No further code is required.

    Purchases & subscriptions

    By default the SDK observes StoreKit 2 and automatically reports verified transactions - subscription renewals, purchases completed on another device, and Ask-to-Buy approvals. The SDK never finishes transactions; that remains your app's responsibility.

    One line is required in your purchase flow. Apple does not deliver a purchase made with Product.purchase() to background observers on the same device, so report it after a successful purchase:

    let result = try await product.purchase()
    if case .success(.verified(let transaction)) = result {
        TapAttribution.shared.logPurchase(transaction)   // ← add this line
        await transaction.finish()
    }

    Safe to double-report

    Transactions are deduplicated by transaction ID, so combining logPurchase(_:) with automatic tracking never counts revenue twice.

    Fixed revenue events

    For conversions with a predetermined value - a qualified lead, an ad view, server-granted credit - report the amount directly:

    TapAttribution.shared.logRevenue(5.00, currency: "USD",
                                     name: "qualified_lead",
                                     revenueType: .fixed)

    Use ISO 4217 currency codes ("USD", "EUR", "GBP", …). You can also pass revenueType: .purchase or .subscription if you track store transactions yourself.

    Custom events

    Log any named event, optionally with parameters:

    TapAttribution.shared.logEvent("onboarding_complete")
    
    TapAttribution.shared.logEvent("level_up", parameters: [
        "level": 7,
        "difficulty": "hard",
        "hardcore": true
    ])
    • Event names: 1–64 characters. We recommend lowercase snake_case and a consistent naming scheme across your app.
    • Parameter values: strings, numbers, booleans, dates, URLs, and arrays/dictionaries of those.

    User identity & opt-out

    To connect events to your own user IDs (for joining with your internal data), set the customer user ID after login:

    TapAttribution.shared.setCustomerUserId("your-user-id")   // after sign-in
    TapAttribution.shared.setCustomerUserId(nil)               // after sign-out

    If a user opts out of analytics in your app, disable tracking. This clears any pending events and stops new ones from being recorded. The setting applies per launch, so call it on every launch for opted-out users:

    TapAttribution.shared.setTrackingEnabled(false)

    Configuration reference

    All options on TapConfiguration:

    OptionDefaultDescription
    apiKey-Your Tap SDK API key. Required.
    autoTrackPurchasestrueAutomatically observe and report StoreKit 2 transactions.
    flushInterval15Seconds between automatic delivery attempts.
    batchSize20Queued-event count that triggers an immediate delivery.
    logLevel.warnConsole verbosity: .debug, .info, .warn, .error, or .none. Use .debug during integration.

    Events are delivered on the flush interval, when the batch size is reached, and when the app moves to the background. Failed deliveries are retried automatically; events persist across app launches until accepted.

    Testing your integration

    1. Set logLevel: .debug in your configuration and launch the app. You should see [TapAttribution] log lines confirming the SDK started and the install event was queued.
    2. Trigger a custom event and a test purchase (StoreKit sandbox or a .storekit configuration file work fine) and confirm the Queued and Delivered log lines appear.
    3. Verify the events appear in your client dashboard within a few minutes.

    Simulator limitation

    Apple's attribution token is only available on physical devices - installs from the iOS Simulator are reported without a token. Full end-to-end campaign attribution can only be validated with a real Apple Ads tap-through on a real device; organic installs will simply show as unattributed, which is expected.

    To re-test the install event, delete the app from the device and reinstall - the install fires once per fresh install.

    Privacy & App Store disclosure

    The SDK ships with an embedded privacy manifest (PrivacyInfo.xcprivacy), which Xcode automatically includes in your app's aggregated privacy report. The SDK:

    • Does not collect the IDFA and does not require the App Tracking Transparency prompt.
    • Collects: the identifier-for-vendor, an anonymous per-install ID, device model, OS version, locale, timezone, purchase events, and the custom events you log.

    In App Store Connect's privacy questionnaire, this typically corresponds to Device ID and Purchase History collected for Analytics, not used for tracking. Review with your own legal/privacy team, since your answers depend on how you use the data overall.

    Support

    Questions or issues during integration? Reach out to your account manager, or contact us through theasoproject.com/contact. Include your bundle ID and SDK log output (logLevel: .debug) to help us resolve issues quickly.

    Related services and guides

    Need help integrating the Tap Attribution SDK?

    Contact your account manager or our team for help with your integration and SDK API key.

    Talk to our team