document.browsingTopics() returns a Promise that fulfills with up to three topic objects (one per recent epoch) for interest-based advertising. By default it also marks the current page as observed for topic calculation.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call document.browsingTopics. Start with this line.
JavaScript
document.browsingTopics([options])
Call
What it does
document.browsingTopics([options])
Primary signature.
document.browsingTopics(...)
Call with the arguments your case needs.
Built into the browser. Call browsingTopics(...) on document — no import required.
Library declarations
JavaScript
document.browsingTopics([options])
Parameters
Parameter
Description
options.skipObservation
Optional. true = do not observe this visit (default false)
Return Value
Return Value
Description
*
Promise of topic object array (0–3)
JavaScript Examples
Example 1 — Await Topics Safely
Detect the method, await the Promise, and catch enrollment/policy errors.
It returns a Promise that fulfills with an array of up to three topic objects — one from each of the last three epochs — representing the user’s top topics for interest-based advertising (MDN).
MDN marks Document.browsingTopics() as Deprecated (pending removal) and Non-standard. Chrome withdrew certain Privacy Sandbox features including the Topics API. Do not use it in new production code.
A Promise resolving to an array of topic objects. Each object includes topic (ID), configVersion, modelVersion, taxonomyVersion, and version.
An optional boolean. When true, the browser does not record the current page visit as observed for topics calculation. Default is false.
It throws NotAllowedError if blocked by a browsing-topics Permissions Policy, or if the site is not enrolled in the Privacy Sandbox enrollment process.
MDN advises preferring Topics API HTTP header features when you can modify headers, and falling back to browsingTopics() only when headers cannot be changed — and only while the API still exists.