How Safari's ITP Uses Machine Learning to Stop Trackers

Safari’s Intelligent Tracking Prevention (ITP) protects user privacy by using on-device machine learning to identify and isolate cross-site trackers. This article breaks down the exact mechanisms ITP uses to monitor domain behavior, how its classification model evaluates tracking patterns entirely on your local device, and the specific actions Safari takes to block domains once they are flagged as trackers.

1. Local Data Collection and Statistics

ITP operates entirely on the user's device, meaning your browsing history is never sent to Apple or any remote server for analysis. As you browse the web, Safari’s WebKit engine silently gathers specific statistics about the domains your browser interacts with.

ITP focuses on three primary vectors of cross-site tracking:

  • Subresource Loads: When you visit Website A, it may load images, scripts, or iframes hosted on Website B. ITP counts how many different first-party websites load resources from Website B.
  • Redirects: Trackers often bounce users through multiple domains quickly to pass along tracking IDs. ITP monitors how frequently a domain redirects you to other unique domains.
  • Subframe Navigations: ITP tracks when embedded frames within a webpage navigate to different domains to share user data.

2. The Machine Learning Classifier

To determine if a domain is a tracker, ITP feeds the collected statistics into a supervised machine learning model.

Apple initially trained this model using known tracking domains and normal, non-tracking domains to teach the algorithm what tracking behavior looks like. The resulting model is shipped directly inside the Safari browser.

As you browse, your device inputs the locally collected domain statistics into this pre-trained classifier. The model looks at features such as the "collision" of domains—specifically, the sheer breadth of different websites where a single third-party domain appears. If a domain is loaded across a high number of unrelated websites or participates in chain redirects, the machine learning model scores it above a specific threshold and classifies it as having cross-site tracking capabilities.

3. Distinguishing First-Party Interaction

Identifying a tracker is only half the battle; ITP must also ensure it does not break websites you actually want to use. For example, a major social media site might track you across the web using embedded "Like" buttons, which the machine learning model will flag. However, you might also log into that social media site directly.

To handle this, ITP tracks "user interaction." If you intentionally tap, click, or type on a website as a first-party domain (the actual URL in your address bar), ITP records that you have a legitimate relationship with that site, temporarily exempting it from the harshest data-purging rules.

4. Enforcement and Blocking

Once the on-device machine learning model classifies a domain as a tracker, ITP immediately restricts how that domain can use browser storage and cookies:

  • Third-Party Cookie Blocking: The classified domain is completely blocked from using cookies when loaded as a third-party resource on another website.
  • Bounce Tracking Mitigation: If a classified tracker attempts to circumvent rules by briefly redirecting you through its own domain (making it a temporary first-party site), and you do not interact with it, ITP deletes all of its website data—including cookies, LocalStorage, and IndexedDB—after a short grace period (typically 24 hours to 7 days, depending on the method used).
  • Referrer Downgrading: When navigating from a site to a classified tracker, ITP strips the referrer URL down to just the origin domain, hiding the specific page you were previously viewing.

By running this continuous loop of statistics gathering, machine learning classification, and storage purging locally on the device, ITP adapts to new tracking domains dynamically without relying on manually updated blocklists.