Skip to content

Apps

iOS & macOS (Swift)

Analytics for iOS, iPadOS, macOS, tvOS, watchOS and visionOS — no dependencies, no IDFA, no App Tracking Transparency prompt.

In progress: The iOS SDK is feature-complete but still being tested on real devices and with Swift 6. Feel free to try it — for production we currently recommend the web script, Android and JavaScript.

Overview

  • No IDFA, no IDFV, no device model, no install id — nothing persistent, no fingerprinting.
  • Nothing is written to the device (no UserDefaults, no files, no Keychain). Events and the session id live in memory only.
  • Batched delivery via an ephemeral URLSession (no cookies, no cache) with a neutral User-Agent: trackd-ios/<version>.
  • Ships a privacy manifest (PrivacyInfo.xcprivacy).

Requirements: Xcode 15+ (Swift 5.9), iOS 13+ / macOS 11+ / tvOS 13+ / watchOS 7+ / visionOS 1+.

Install

A tagged Swift package is coming. Until then copy the sources into your app target:

Then leave out import Trackd in the examples (the code is part of your module). Alternatively add the sdk/ios folder as a local Swift package.

macOS (sandboxed, Mac Catalyst): enable Outgoing Connections (Client), otherwise all requests fail silently:

<!-- *.entitlements (Debug + Release) -->
<key>com.apple.security.network.client</key>
<true/>

Setup

import SwiftUI

@main
struct MyApp: App {
    init() {
        Trackd.configure(websiteId: "YOUR_WEBSITE_ID")
        // self-hosted: Trackd.configure(websiteId: "…", host: "https://stats.example.com", debug: true)
    }
    var body: some Scene { WindowGroup { ContentView() } }
}

UIKit: call Trackd.configure(...) in application(_:didFinishLaunchingWithOptions:), on the main thread. Events tracked before configure stay in memory and are sent afterwards. In the dashboard, create a project with your bundle id (e.g. com.example.mygame) as domain.

Track purchases & revenue

Send revenue right after a successful purchase — with StoreKit 2, when product.purchase() returns a verified transaction:

let result = try await product.purchase()
if case .success(.verified(let transaction)) = result {
    Trackd.revenue(NSDecimalNumber(decimal: product.price).doubleValue,
                   currency: product.priceFormatStyle.currencyCode,
                   orderId: String(transaction.id))
    await transaction.finish()
}

Don’t send restored purchases again. Subscription renewals happen in the App Store without your app — they only show up if you report them server-side via the Collect API. The event is called purchase and carries { amount, currency, order_id }. It shows up under Revenue and can be a funnel step: a Paywall → purchase funnel (screen view /paywall → event purchase) shows how many sessions with a paywall actually buy. The Analytics page calculates this conversion automatically once it detects a paywall screen, and Funnels has a template for it. Currencies and edge cases: Revenue tracking.

API

Trackd.configure(websiteId: String,
                 host: String = "https://trackd.one",
                 debug: Bool = false,
                 flushInterval: TimeInterval = 30,   // seconds
                 flushAt: Int = 20)

Trackd.screen("Home")                                   // screen view (alias: screenView)
Trackd.screen("Settings/Profile", title: "Profile")
Trackd.event("signup", data: ["plan": "pro", "trial": true])
Trackd.revenue(4.99, currency: "EUR", orderId: "order-123")   // → event "purchase"
Trackd.flush()
Trackd.setEnabled(false)                                // opt-out: stop + clear the queue

// Game & media helpers
Trackd.gameStart(level: 1, mode: "hard")
Trackd.levelComplete(5, score: 1200, timeMs: 45_000)
Trackd.gameOver(3, reason: "fell")
Trackd.videoWatch("intro", durationMs: 30_000, completed: true)
Trackd.adView("rewarded", adId: "ad-1")
Trackd.tutorialStep(2, total: 5, skipped: false)

data must be flat: String, numbers or Bool. Nested values, dates, nil, NaN and infinity are dropped; the JSON is limited to 4 KB.

Screens with SwiftUI

struct HomeView: View {
    var body: some View {
        List { /* … */ }
            .onAppear { Trackd.screen("Home") }
    }
}

// or with the bundled view modifier
struct SettingsView: View {
    var body: some View {
        Form { /* … */ }
            .trackScreen("Settings")
    }
}

UIKit: Trackd.screen("Home") in viewDidAppear(_:). Never put user data (names, emails, ids) into screen names.

What is sent

Field Source
platform ios, ipados, macos (incl. Mac Catalyst), tvos, watchos, visionos
app_version CFBundleShortVersionString
os_version e.g. iOS 18.1
screen screen resolution in pixels (portrait)
language preferred system language
device tablet (iPad), mobile (iPhone, Watch), desktop (Mac, TV, Vision)

App Store privacy

Usage Data → Product Interaction and Location → Coarse Location (country, derived server-side from the IP), each not linked to the user, not used for tracking, purpose Analytics. Add Purchases → Purchase History if you use revenue. Tracking: No.

Batching, retries & sessions

  • Flush at 20 queued events, 30 s after an event, on flush() and when the app goes to the background — the request then finishes via performExpiringActivity.
  • Max. 50 events / 60 KB per request, max. 500 queued events.
  • Network errors, 5xx, 408, 429 → exponential backoff (1 s … 5 min, honors Retry-After).
  • Session id: 20 random characters, memory only, rotated after 30 minutes without events or 30 minutes in the background.
App dashboard filtered to iOS: users, sessions, screen views, screens and events
This is how your iOS app appears in the dashboard (demo data, filter "iOS").

Ready in minutes

Start the 7-day free trial (no credit card), add your website or app, copy the snippet.

Start free trial