Skip to main content

App Tracking Transparency (ATT)

This guide provides comprehensive instructions for implementing Apple's App Tracking Transparency (ATT) framework with the Trackier Cordova SDK. ATT is required for iOS 14.5+ apps that want to access the Identifier for Advertisers (IDFA) for accurate attribution and tracking.

Overview

App Tracking Transparency (ATT) is Apple's privacy framework that requires apps to request user permission before accessing the IDFA. This is crucial for accurate attribution and tracking on iOS 14.5 and later.

Prerequisites

  • iOS 14.5 or later
  • Xcode 12.0 or later
  • Trackier Cordova SDK installed
  • Access to your app's Info.plist file (located in ios/App/App/Info.plist for Capacitor projects)
  • Cordova IDFA plugin installed (e.g., cordova-plugin-idfa or @sparkfabrik/cordova-plugin-app-tracking-transparency)

Implementation

Step 1: Add Permission Description

Add the following key-value pair to your Info.plist to describe why your app needs tracking permission:

Info.plist
<key>NSUserTrackingUsageDescription</key>
<string>We use tracking to personalize your experience and improve our services.</string>

Step 2: Configure ATT Timeout

note

Important: Always include waitForATTUserAuthorization(timeoutInterval) before initializing the SDK. This ensures the SDK waits for the user's ATT decision before starting tracking, which is required for accurate attribution on iOS 14.5+. You can adjust the timeout value (20 seconds) according to your use case or logic.

Update your app component to configure ATT timeout before SDK initialization:

app.component.ts
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { TrackierCordovaPlugin, TrackierConfig } from '@awesome-cordova-plugins/trackier/ngx';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
})
export class AppComponent {
constructor(
private platform: Platform,
private trackierCordovaPlugin: TrackierCordovaPlugin
) {
this.initializeApp();
}

async initializeApp() {
await this.platform.ready();
await this.initializeTrackierSDK();
}

async initializeTrackierSDK() {
try {
// iOS: Configure ATT timeout (should be called before initialization)
if (this.platform.is('ios')) {
this.trackierCordovaPlugin.waitForATTUserAuthorization(20);
}

const trackierConfig: TrackierConfig = {
appToken: 'YOUR_SDK_KEY',
environment: 'production'
};

await this.trackierCordovaPlugin.initializeSDK(trackierConfig);
console.log('Trackier SDK initialized successfully');
} catch (error) {
console.error('Error initializing Trackier SDK:', error);
}
}
}

Step 3: Request ATT Permission

note

Important: You must manually request ATT permission from the user. The waitForATTUserAuthorization method only configures the SDK to wait for the user's decision. Once the user grants permission, the Trackier SDK will automatically fetch the IDFA and send it to the panel.

Create a service to handle ATT permission requests using a Cordova IDFA plugin:

services/att.service.ts
import { Injectable } from '@angular/core';
import { Platform } from '@ionic/angular';

declare var cordova: any;

@Injectable({
providedIn: 'root'
})
export class AttService {
constructor(private platform: Platform) {}

async requestTrackingPermission(): Promise<void> {
if (!this.platform.is('ios')) {
console.log('ATT is only required on iOS platform');
return;
}

try {
// Check if the AppTrackingTransparency plugin is available
if (typeof cordova !== 'undefined' && cordova.plugins && cordova.plugins.idfa) {
const result = await cordova.plugins.idfa.getInfo();

if (result.trackingPermission === 'notDetermined') {
// Request permission from user
const permissionResult = await cordova.plugins.idfa.requestPermission();
this.handlePermissionResult(permissionResult);
} else {
console.log('ATT permission already determined:', result.trackingPermission);
}
}
} catch (error) {
console.error('Error requesting ATT permission:', error);
}
}

private handlePermissionResult(result: any): void {
console.log('ATT Permission Status:', result.trackingPermission);

switch (result.trackingPermission) {
case 'authorized':
console.log('App Tracking Permission: Authorized');
console.log('IDFA:', result.idfa);
// The Trackier SDK will automatically fetch and send IDFA to the panel
break;
case 'denied':
console.log('App Tracking Permission: Denied');
// The SDK will continue tracking without IDFA
break;
case 'restricted':
console.log('App Tracking Permission: Restricted');
break;
case 'notDetermined':
console.log('App Tracking Permission: Not Determined');
break;
}
}
}

Step 4: Request Permission After App Launch

Call the ATT permission request after the app is fully loaded:

app.component.ts
import { Component } from '@angular/core';
import { Platform } from '@ionic/angular';
import { TrackierCordovaPlugin, TrackierConfig } from '@awesome-cordova-plugins/trackier/ngx';
import { AttService } from './services/att.service';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.scss'],
})
export class AppComponent {
constructor(
private platform: Platform,
private trackierCordovaPlugin: TrackierCordovaPlugin,
private attService: AttService
) {
this.initializeApp();
}

async initializeApp() {
await this.platform.ready();
await this.initializeTrackierSDK();

// Request ATT permission after a short delay
if (this.platform.is('ios')) {
setTimeout(() => {
this.attService.requestTrackingPermission();
}, 1000);
}
}

async initializeTrackierSDK() {
try {
// iOS: Configure ATT timeout (should be called before initialization)
if (this.platform.is('ios')) {
this.trackierCordovaPlugin.waitForATTUserAuthorization(20);
}

const trackierConfig: TrackierConfig = {
appToken: 'YOUR_SDK_KEY',
environment: 'production'
};

await this.trackierCordovaPlugin.initializeSDK(trackierConfig);
console.log('Trackier SDK initialized successfully');
} catch (error) {
console.error('Error initializing Trackier SDK:', error);
}
}
}

How It Works

  1. Configure Timeout: Call waitForATTUserAuthorization(timeoutInterval) before SDK initialization to configure how long the SDK should wait for user permission
  2. Initialize SDK: The SDK initializes and waits for ATT permission decision
  3. Request Permission: You manually request ATT permission from the user (using Cordova IDFA plugin)
  4. User Allows: When user grants permission, the Trackier SDK automatically fetches the IDFA and sends it to the panel
  5. Automatic Tracking: The SDK uses the IDFA for accurate attribution tracking

Key Features

  • waitForATTUserAuthorization(timeoutInterval): Configures the SDK to wait for user's ATT decision before starting tracking. The timeout can be adjusted based on your app's needs.
  • Automatic IDFA Handling: Once permission is granted, the SDK automatically fetches and sends IDFA to the panel.
  • Manual Permission Request: You control when to show the ATT permission dialog to users.
  • Platform-Specific: Only runs on iOS, gracefully skips on other platforms.
warning

Always replace "YOUR_SDK_KEY" with your actual SDK token from the Trackier Panel. Using an incorrect token will cause attribution issues.

Visual Examples

ATT Permission Dialog:

ATT Permission Dialog

IDFA Console Logs:


IDFA Access


IDFA Panel in Trackier Dashboard: When tracking is properly configured with ATT, you can see the IDFA details in the Trackier panel for installs and events:

IDFA Panel Details

This panel shows the IDFA information when users grant tracking permission, allowing for accurate attribution and detailed tracking analytics.

ATT Status Values

StatusDescriptionSDK Behavior
authorizedUser granted permissionFull tracking enabled, IDFA available
deniedUser denied permissionLimited tracking, no IDFA
restrictedSystem restricted (parental controls)Limited tracking, no IDFA
notDeterminedPermission not requested yetWait for user decision

Best Practices

  • Timing: Request permission after app launch (1-2 second delay)
  • User Experience: Explain why tracking is needed before requesting permission
  • Timeout Configuration: Adjust timeout based on your app's flow (default 20 seconds)
  • Platform Check: Always check if running on iOS before calling ATT methods
  • Check Status First: Always check if permission has already been determined before requesting
  • Handle All Cases: Implement proper handling for all ATT status values

Troubleshooting

Common Issues

ATT Permission Not Requested

  • Ensure NSUserTrackingUsageDescription is added to Info.plist
  • Check that the app targets iOS 14.5 or later
  • Verify the permission request is called after app launch

IDFA Not Available

  • Check if user granted permission (status should be authorized)
  • Ensure the device supports IDFA (not available on simulator)
  • Verify the app is not restricted by parental controls

SDK Initialization Issues

  • Make sure waitForATTUserAuthorization is called before SDK initialization
  • Check that the timeout value is appropriate for your app flow
  • Verify the SDK token is correct

Platform Check Not Working

  • Ensure this.platform.is('ios') is correctly implemented
  • Verify the Platform service is properly imported from @ionic/angular

Support

For technical support and questions:


This guide provides comprehensive implementation of App Tracking Transparency with the Trackier Cordova SDK, ensuring compliance with Apple's privacy requirements while maintaining accurate attribution and tracking capabilities.