GuidesMobile

iOS Swift analytics SDK, cookieless and hosted in Germany

Swift analytics for iOS, macOS, tvOS and watchOS. Cookieless, EU-hosted.

Privytics uses the open-source OpenPanel Swift SDK to send events from iOS, macOS, tvOS and watchOS apps. You add the Swift package, call OpenPanel.initialize once at launch with your client ID and the Privytics API URL, then call OpenPanel.track wherever something happens worth measuring. The whole setup is about five lines in your app delegate or App struct.

Why Swift (iOS) teams use Privytics

No advertising identifier, no ATT prompt of its own

The SDK imports neither AdSupport nor AppTrackingTransparency and never reads the IDFA. It sends events to the API rather than storing an identifier on the device. The anonymous visitor id is computed server-side and resets every day. Adding it does not, by itself, give you a reason to show an App Tracking Transparency prompt.

Straightforward App Store privacy answers

App Store Connect asks you to declare what data you collect and whether it is linked to identity or used for tracking. The SDK sends the event name and your properties along with device context: user agent, OS name and version, and device model. There is no persistent identifier and no cross-app tracking to declare. If you call identify() with your own profile ID, that becomes linked data and you declare it accordingly.

Data is stored in Germany, including from mobile clients

Every event your app sends goes to api.privytics.com and is stored in EU data centres in Germany. That matters more on mobile than on web, because a mobile SDK is a direct client-to-server pipe with no CDN or proxy in between that you could relocate later.

One SDK across every Apple platform

The package supports iOS 13.0+, macOS 10.15+, tvOS 13.0+ and watchOS 6.0+ from a single import, and the call sites are identical. A shared analytics layer in a multiplatform target does not need per-platform branches.

Set it up

About five minutes, on the free plan, without a credit card.

  1. Add the Swift package

    In Xcode, choose File > Add Packages and enter the repository URL https://github.com/Openpanel-dev/swift-sdk. For a package-based project, declare it in Package.swift as shown. The package is OpenPanel's, published under the Openpanel-dev GitHub organisation.

    dependencies: [
        .package(url: "https://github.com/Openpanel-dev/swift-sdk")
    ]
  2. Initialise with the Privytics API URL

    Call this once at app launch, before any track calls. Setting apiUrl is what points the SDK at Privytics: left unset, it falls back to the upstream OpenPanel host and your events will not reach us. Replace YOUR_CLIENT_ID with the client ID from your project settings.

    import OpenPanel
    
    OpenPanel.initialize(options: .init(
        clientId: "YOUR_CLIENT_ID",
        apiUrl: "https://api.privytics.com"
    ))
  3. Track an event

    Call track from anywhere. The SDK is designed to be thread-safe, so you do not need to hop to the main queue.

    OpenPanel.track(name: "Button Clicked", properties: ["button_id": "submit_form"])
  4. Track screen views and app lifecycle

    Set automaticTracking to true and the SDK records app_opened and app_closed for you. There is no dedicated screen view method, so send screen views as ordinary named events from onAppear or viewDidAppear. Use setGlobalProperties for values you want attached to every event.

    OpenPanel.initialize(options: .init(
        clientId: "YOUR_CLIENT_ID",
        apiUrl: "https://api.privytics.com",
        automaticTracking: true
    ))
    
    OpenPanel.setGlobalProperties([
        "app_version": "1.0.2",
        "environment": "production"
    ])
    
    // In a SwiftUI view
    .onAppear {
        OpenPanel.track(name: "screen_view", properties: ["screen": "Settings"])
    }

Privytics runs the open-source OpenPanel engine, so the upstream Swift (iOS) SDK reference applies here too. Point apiUrl at Privytics and the data lands in your Privytics project.

Questions

Do I need to show an App Tracking Transparency prompt?

ATT applies when you access the IDFA or track users across apps and websites owned by other companies. This SDK does neither: it imports no AdSupport or AppTrackingTransparency and stores no device identifier. You remain responsible for your own App Store privacy declarations and for reviewing your full app against Apple's rules.

How do I link events to a logged-in user?

Call OpenPanel.identify(payload:) with an IdentifyPayload carrying your own profileId, plus optional firstName, lastName, email, avatar and properties. This is opt-in and it is data linked to identity, so you need your own lawful basis for it and you should declare it in App Store Connect.

Does the Swift SDK work on macOS, tvOS and watchOS?

Yes. The package supports iOS 13.0+, macOS 10.15+, tvOS 13.0+ and watchOS 6.0+, and requires Xcode 12.0+ with Swift 5.3+. The API is the same on every platform.

How do I stop tracking in debug builds?

Pass disabled: true in the initialise options, or pass a filter closure that receives the payload and returns false for events you do not want sent. Both are set at initialisation.