Use Cases
E-commerce Apps Track purchases, cart additions, and product views. Attribute revenue back to ad campaigns on Meta, Google, and TikTok. Subscription Apps Monitor trial starts, conversions, and renewals with iOS 14+ attribution via SKAdNetwork. SaaS Mobile Apps Track feature usage, user engagement, and subscription upgrades with cross-device attribution. Mobile Games Track in-app purchases, level completions, and retention with gaming-optimized SKAdNetwork templates.Before You Start
- You have a DATALYR account
- You’ve created a workspace
- You have an iOS app project in Xcode
- iOS 13.0+ deployment target
- Swift 5.0+
Step 1: Get Your API Key
- Log in to your DATALYR dashboard
- Go to Settings → API Keys
- Create a new API key or copy an existing one
- Your API key will start with
dk_
Step 2: Install the SDK
Option 1: Swift Package Manager (Recommended)
- In Xcode, select File → Add Package Dependencies
- Enter the repository URL:
- Select version 1.0.2 or later
- Add DatalyrSDK to your app target
Option 2: CocoaPods
Add to yourPodfile:
Option 3: Manual Installation
- Download the SDK from GitHub Releases
- Drag
Sources/DatalyrSDKfolder into your Xcode project - Ensure “Copy items if needed” is checked
Step 3: Initialize the SDK
SwiftUI App
Add to your App struct:UIKit App
Add to your AppDelegate:Step 4: Track Your First Event
Test that tracking works:Step 5: Verify Tracking
- Run your app in the simulator or on a device
- Go to your DATALYR dashboard
- Click Events in the sidebar
- You should see an
app_openedevent within 10 seconds
What Gets Tracked Automatically
WhenenableAutoEvents is enabled (default: true):
app_install- First app openapp_open- App launchesapp_background- App enters backgroundapp_foreground- App returns to foregroundapp_update- App version changessession_start- New session beginssession_end- Session expires
Track Custom Events
Track any custom event with optional properties:Track Purchases
Track purchase events with revenue:Track Subscriptions
Track subscription events for IAP subscriptions:Identify Users
Identify users after signup or login for cross-device attribution:Track Screen Views
Track screen or view controller views:SKAdNetwork Support (iOS 14+)
Enable SKAdNetwork conversion value tracking:SKAdNetwork Templates
Choose a template based on your business model:- ecommerce: Purchase events, revenue ranges
- gaming: Level completion, in-app purchases, retention
- subscription: Trial starts, conversions, renewals
Identity Resolution
The SDK includes persistent anonymous IDs for complete user journey tracking:Attribution Tracking
The SDK automatically tracks:- Deep links and Universal Links
- UTM parameters
- Platform click IDs (fbclid, gclid, ttclid)
- Install referrer
- Campaign data
Session Management
Sessions are automatically tracked with a 30-minute timeout:Deep Link Handling
Track deep link opens:Offline Support
Events are automatically queued when offline and sent when connection is restored:Debug Mode
Enable debug logging during development:- Event tracking logs
- Network requests
- Queue operations
- Attribution updates
- Error messages
Privacy & Compliance
App Tracking Transparency (iOS 14.5+)
Request tracking permission:User Consent
Handle user consent for tracking:Configuration Options
Troubleshooting
Events not appearing?- Check API key is correct (starts with
dk_) - Enable debug mode to see logs
- Verify network connectivity
- Check
getStatus()for queue info - Call
flush()to force send events
- Get API key from: https://app.datalyr.com/settings/api-keys
- Ensure key is active
- Check key permissions
Next Steps
Verify Tracking
Confirm events are coming through
Track Custom Events
Learn the full event tracking API
Connect Integrations
Link Meta, Google, TikTok Ads
View Dashboard
See your tracking data