# Add top lists and filters

URL: https://docs.analytics.remcostoeten.nl/docs/tutorial/add-top-lists-and-filters

> Step 5 of 7. Show the top pages, referrers, browsers, devices and countries, filter on a click and track each change as a custom event.

This step turns the page into a dashboard you can explore. The view becomes state: a period, a traffic filter and any number of dimension filters. Clicking a row in a top list adds a filter, and every panel reads again with it.

## 1. Add the view state and the panels

<StepDiff
  step="5"
  notes="[
  {
    file: &#x22;src/state.ts&#x22;,
    match: &#x22;export type ViewState&#x22;,
    text: &#x22;Everything a read depends on, in one value.&#x22;,
  },
  {
    file: &#x22;src/api.ts&#x22;,
    match: &#x22;project.period(state.period).traffic(state.traffic).where(state.filters)&#x22;,
    text: &#x22;where() takes the filters as an object with one value per dimension. Each panel reads from this scope.&#x22;,
  },
  {
    file: &#x22;src/components/breakdown-table.tsx&#x22;,
    match: &#x22;scope.breakdown(dimension&#x22;,
    text: &#x22;The top values of one dimension, with visitors, pageviews and each row's share.&#x22;,
  },
  {
    file: &#x22;src/components/country-table.tsx&#x22;,
    match: 'scope.map({ level: &#x22;country&#x22;, limit: 25 })',
    text: &#x22;map() groups by place and returns the total number of countries next to the first 25.&#x22;,
  },
  {
    file: &#x22;src/app.tsx&#x22;,
    match: 'analytics.track(&#x22;filter_added&#x22;, { dimension })',
    text: &#x22;Typed by the Events map from step 2. The page tracks how it is used.&#x22;,
  },
  {
    file: &#x22;src/app.tsx&#x22;,
    match: &#x22;const scopeKey = JSON.stringify(state)&#x22;,
    text: &#x22;The read hook runs again when the key changes. Step 6 replaces it with the URL hash.&#x22;,
  },
]"
/>

## 2. What a top list returns

The top pages of this site:



Click a page in the dashboard: a chip appears under the controls, and every panel shows only visits to that page. Click the chip to remove the filter.

Next, [keep the view in the URL](https://docs.analytics.remcostoeten.nl/docs/tutorial/keep-the-view-in-the-url.md).
