Developers » AS2 tagging » Apple » Users » Respecting data privacy
Respecting data privacy
- iOS
- watchOS
- tvOS
Foreword
So that you can respect user privacy and be in accordance with the regulations in different countries, the tracker makes two features available:
- Disabling user tracking
- Hashing user IDs
- Gestion de la sauvegarde des hits hors ligne (si l’option est activée)
Disabling user tracking (opt-out)
If your application offers a screen allowing the user to enable or disable statistical tracking, you can save this information via the static optOut property of the ATInternet class.
Hits will nonetheless be sent. Only the idclient variable enabling use tracking will contain the value opt-out
To change this behavior, you can use the configuration key sendHitWhenOptOut available since version 2.13.0 of the Tracker. By passing the value to false (true by default), you will prevent the hits from being sent when the user is in opt-out mode.
let tracker: Tracker = ATInternet.sharedInstance.defaultTracker tracker.setSendHitWhenOptOutEnabled(false, sync: true, completionHandler: nil) // Tracker is now preventing hit from being sent when the user is in opt-out modeTracker* tracker = [ATInternet sharedInstance].defaultTracker; [tracker.ecommerce setSendHitWhenOptOutEnabled:NO sync:YES completionHandler:nil]; // Tracker is now preventing hit from being sent when the user is in opt-out mode
Examples
- Disabling user tracking
@IBAction func disableTracking(sender: UIButton) { // deprecated : Tracker.doNotTrack = true ATInternet.optOut = true }
- (IBAction)disableTracking:(UIButton *)sender { // deprecated : Tracker.doNotTrack = YES; Tracker.optOut = YES; }
- Recovering user tracking status
override func viewDidLoad() { super.viewDidLoad() // deprecated : Tracker.doNotTrack let optOut = ATInternet.optOut }
- (void)viewDidLoad { [super viewDidLoad]; // deprecated : Tracker.doNotTrack BOOL optOut = ATInternet.optOut; }
Hashing user ID
The SDK allows for the automatic addition of user ID in your hits (uuid, idfv, idfa). You may also add your own user ID via the trackers setParam method.
To ensure visitor anonymity, all while keeping their identification in your analyses, it is possible to hash the unique ID (SHA-256). To do this, use the trackers setHashUserIdEnabled method as follows:
import UIKit import Tracker class ViewController: UIViewController { let tracker: Tracker = ATInternet.sharedInstance.defaultTracker override func viewDidLoad() { super.viewDidLoad() tracker.setHashUserIdEnabled(true, completionHandler: { isSet in print("User ID will now be hashed") } } }
#import "ViewController.h" #import "SmartTracker/SmartTracker-Swift.h" @interface ViewController () @property (nonatomic, strong) Tracker *tracker; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self.tracker setHashUserIdEnabled:YES completionHandler:^(BOOL isSet) { NSLog(@"hashing enabled") }]; } @end
Offline hit customization
Offline hits are saved in the application documentDirectory directory. However Apple allows this directory to be synchronized with iCloud. To disable any backup, you can use the flag preventICloudSync of the ATInternet class.
You can also configure where the offline hit are saved with the static property databaseDirectory of the ATInternet class.
If the path is incorrect, the database won’t be initialized and the offline hits will be lost
- Deactivation of the iCloud backup
// Before any Tracker usage ATInternet.preventICloudSync = true
// Before any Tracker usage ATInternet.preventICloudSync = YES;
- Database path customization
// Before any Tracker usage ATInternet.databaseDirectory = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).last!
// Before any Tracker usage ATInternet.databaseDirectory = ATInternet.databaseDirectory = [[NSURL alloc] initWithString:[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]];