Topics API demo

This site provides a basic demo of Topics using the document.browsingTopics() JavaScript API.

An iframe with src= (i.e. with the same origin as this page) calls document.browsingTopics(). This iframe is embedded on several sites, to observe topics:

Topics observed will be displayed on this page (see below).

When topics are observed, a fetch() request is made to, including the parameter {browsingTopics: true}. This causes the request to include observed topics in a sec-browsing-topics header. A request like this would normally be used for ad selection but, for the demo, the server responds with any request headers it receives, so that sec-browsing-topics values can be displayed below.

This demo isn't anything like a real-world implementation: it only serves to show how topics can be included in request headers.

Topics header demo

Topics can also be accessed from HTTP headers for a fetch() request or by adding a browsingtopics attribute to an iframe tag: see

Using HTTP headers to access Topics is more performant than using the JavaScript API demonstrated here.

Try out the demo

  1. Run Chrome from the command line using the following feature flags:


    Make sure that chrome://flags/#privacy-sandbox-ads-apis is disabled, since the defaults from this will override the command-line flags (in particular, the epoch duration).

    This site is awaiting enrollment, so enable chrome://flags/#privacy-sandbox-enrollment-overrides and add the following URLs:,,,,,,,,,

    Alternatively, include the command line flag --args --disable-features=EnforcePrivacySandboxAttestations

  2. Open this page.
  3. Visit each of the sites listed above in a separate tab.
  4. The most popular topics observed for the most recent three epochs will be displayed below, refreshed every second. The epoch length is set to 15 seconds using the flags above (the default length is one week).

If no topics are displayed, navigate repeatedly to the pages listed above, e.g. by refreshing each page (not hard-refresh).

The list of topics is only updated if there is a change in observed topics.

You may see unexpected results. Topics inference is not deterministic, and there is a 5% chance that a random topic is returned for each epoch.

No topics observed yet: try visiting one of the sites above.

sec-browsing-topics request headers will be displayed here.