Document: browsingTopics() method

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Warning: This feature is currently opposed by two browser vendors. See the Standards positions section below for details of opposition.

Note: An Enrollment process is required to use this feature in your applications.

The browsingTopics() method of the Document interface returns a promise that fulfills with an array of objects representing the top topics for the user, one from each of the last three epochs. These topics could then be returned to the ad tech platform in a subsequent fetch request. By default, the method also causes the browser to record the current page visit as observed by the caller, so the page's hostname can later be used in topics calculation.

See Using the Topics API for more details.

Note: browsingTopics() does not rely on HTTP headers to send topics and mark topics as observed like the other Topics API enabling features, but it is somewhat less performant. You are advised to use one of the HTTP header-using features, falling back to browsingTopics() only in situations where the headers cannot be modified.

Syntax

js
browsingTopics()
browsingTopics(options)

Parameters

options Optional

An options object, which can contain the following properties:

skipObservation

A boolean value that, if set to true, causes the browser to not observe topics when browsingTopics() is invoked. The default is false, which causes topics to be observed.

Return value

A Promise that fulfills with an array of up to three objects representing the current user's selected topics for the last three epochs. Each object contains the following properties:

configVersion

A string identifying the algorithm (other than the model part) used to calculate the topic.

modelVersion

A string representing the model used to classify a string (such as a web page's hostname) into topic IDs.

taxonomyVersion

A string representing the taxonomy version used.

topic

A number representing the ID of the topic, which can be used by the browser to retrieve the topic from the taxonomy (see an example taxonomy of interests).

version

The configVersion, modelVersion, and taxonomyVersion, concatenated with colons (:) between each.

The exact property values may vary by browser implementation. An example object from Chrome might look as follows:

json
{
  "configVersion": "chrome.1",
  "modelVersion": "1",
  "taxonomyVersion": "1",
  "topic": 43,
  "version": "chrome.1:1:1"
}

Exceptions

NotAllowedError DOMException

Thrown if:

Examples

js
// Get an array of top topics for this user
const topics = await document.browsingTopics();

// Request an ad creative
const response = await fetch("https://ads.example/get-creative", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify(topics),
});

// Get the JSON from the response
const creative = await response.json();

// Display ad

Specifications

This feature is not part of an official standard, although it is specified in the Topics API Unofficial Proposal Draft.

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
browsingTopics
Deprecated Non-standard
Chrome – Full support
Chrome 126 (Release date: 2024-06-11)
footnote Full support
Edge – Full support
Edge 126 (Release date: 2024-06-13)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 112 (Release date: 2024-07-11)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 126 (Release date: 2024-06-11)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 83 (Release date: 2024-06-25)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 28 (Release date: 2025-04-02)
footnote Full support
WebView Android – Full support
WebView Android 126 (Release date: 2024-06-11)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.

See also