Delivery Options
- ADServices framework: Native Apple attribution API
- SKAdNetwork: Privacy-preserving attribution for iOS 14.5+
- Mobile Measurement Partner SDK: Third-party attribution (AppsFlyer, Adjust, etc.)
- Search Ads API: Server-side campaign management
ADServices Framework Integration
Step 1: Add Framework to Xcode
Add the ADServices framework to your app target:
- Select your project in Xcode
- Select your app target
- Go to "Frameworks, Libraries, and Embedded Content"
- Click "+" and add "AdServices.framework"
- Set to "Do Not Embed"
Step 2: Import Framework
import AdServices
Step 3: Request Attribution Token
func getSearchAdsAttribution() {
guard let token = try? AAAttribution.attributionToken() else {
print("Failed to get attribution token")
return
}
// Send token to your server for validation
sendAttributionToken(token)
}
func sendAttributionToken(_ token: String) {
let url = URL(string: "https://api.yourdomain.com/attribution")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let body = ["token": token]
request.httpBody = try? JSONSerialization.data(withJSONObject: body)
URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
print("Attribution error: \(error)")
return
}
// Handle response
}.resume()
}
SKAdNetwork Configuration
Step 1: Update Info.plist
Add SKAdNetwork IDs to your Info.plist:
<key>SKAdNetworkItems</key>
<array>
<dict>
<key>SKAdNetworkIdentifier</key>
<string>cstr6suwn9.skadnetwork</string>
</dict>
<!-- Add additional network IDs as needed -->
</array>
Step 2: Register Conversion Events
import StoreKit
func registerConversion(value: Int) {
// Value must be between 0-63 for SKAdNetwork
if #available(iOS 14.0, *) {
SKAdNetwork.updateConversionValue(value)
}
}
// Example: Register purchase conversion
func didCompletePurchase() {
registerConversion(value: 1) // Map to your conversion schema
}
Step 3: Advanced Conversion Value Mapping
import StoreKit
@available(iOS 16.1, *)
func updateConversionValue(revenue: Double, coarse: SKAdNetwork.CoarseConversionValue) {
SKAdNetwork.updatePostbackConversionValue(
fineValue: calculateFineValue(revenue),
coarseValue: coarse
) { error in
if let error = error {
print("Conversion update failed: \(error)")
}
}
}
func calculateFineValue(_ revenue: Double) -> Int {
// Map revenue to 0-63 scale
switch revenue {
case 0..<10: return 1
case 10..<25: return 2
case 25..<50: return 3
case 50..<100: return 4
default: return 5
}
}
Mobile Measurement Partner Integration
AppsFlyer Example
import AppsFlyerLib
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
AppsFlyerLib.shared().appsFlyerDevKey = "YOUR_DEV_KEY"
AppsFlyerLib.shared().appleAppID = "YOUR_APP_ID"
AppsFlyerLib.shared().waitForATTUserAuthorization(timeoutInterval: 60)
return true
}
func applicationDidBecomeActive(_ application: UIApplication) {
AppsFlyerLib.shared().start()
}
Adjust Example
import Adjust
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let adjustConfig = ADJConfig(
appToken: "YOUR_APP_TOKEN",
environment: ADJEnvironmentProduction
)
adjustConfig?.logLevel = ADJLogLevelVerbose
Adjust.appDidLaunch(adjustConfig)
return true
}
App Tracking Transparency
Request Permission (iOS 14+)
import AppTrackingTransparency
import AdSupport
func requestTrackingAuthorization() {
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization { status in
switch status {
case .authorized:
// Tracking authorized - use IDFA
let idfa = ASIdentifierManager.shared().advertisingIdentifier
print("IDFA: \(idfa)")
case .denied, .restricted, .notDetermined:
// Use SKAdNetwork for attribution
print("Tracking not authorized - using SKAdNetwork")
@unknown default:
break
}
}
}
}
Update Info.plist for ATT
<key>NSUserTrackingUsageDescription</key>
<string>This app would like to track you across apps and websites to measure advertising effectiveness.</string>
Validation Checklist
- ADServices framework linked to target
- Attribution token API called on first app launch
- SKAdNetwork IDs registered in Info.plist
- Conversion values mapped to business events
- ATT prompt configured and tested
- Attribution data verified in Search Ads dashboard
- MMP SDK integrated (if applicable)
- Privacy policy updated with tracking disclosure