breat.fr

Legacy statistics

Brivacia can keep your old analytics totals without importing old pages, old URLs or old tracking problems.

Use this when you want a clean Brivacia start, but you still want your old all-time numbers to be included in the global statistics.

Legacy statistics are not a full import. They are a small historical file that Brivacia reads automatically.

Why this exists

Old analytics data is often messy, especially on websites that have existed for many years.

Common problems include:

A full import can bring all of this old detail back into Brivacia. This may pollute your new statistics with obsolete pages, duplicate URLs, wrong languages or old tracking mistakes.

Brivacia intentionally tracks pages without query strings. For example, these URLs are treated as the same page:

/about
/about?utm_source=newsletter
/about?lang=en
/about?fbclid=123

This keeps modern Brivacia statistics clean. Legacy statistics follow the same idea: keep the useful historical totals, but do not recreate old query-string variants as pages.

Generating the file

There are two ways to get archives/legacy_stats.json, depending on where your old data lives.

From data already in Brivacia (recommended)

If you already have data inside Brivacia — for example after a full import from another tool, or simply from tracking a site for a while — the dashboard can generate this file for you.

Go to Export → Legacy statistics. Brivacia aggregates your entire history (live database and any already-archived years) for every configured site, and downloads a ready-to-use legacy_stats.json. Upload it to archives/ on your server and you're done — no manual editing needed.

This is the easiest path if you just did a full import and want to switch to a clean reset (see Clean reset workflow below).

Written by hand

If your old numbers never went through Brivacia at all — for example you're typing totals from an old Google Analytics export, a spreadsheet, or a report — you'll need to write the JSON file yourself, following the format described below.

How it works

Create this file:

archives/legacy_stats.json

Brivacia detects it automatically.

There is no import button for this file, no upload screen and no database change — you place it directly in archives/ (either the one downloaded from Export, or one you wrote by hand).

The file is used only for the All period.

JSON format

The root keys are Brivacia site codes.

Example with one site:

{
  "example": {
    "totals": {
      "unique_visitors": 1000,
      "visits": 1200,
      "pageviews": 3000,
      "bots": 50
    },
    "countries": {
      "FR": 600,
      "US": 250,
      "DE": 100
    },
    "referrers": {
      "google.com": 42,
      "example.com": 12
    }
  }
}

Example with multiple sites:

{
  "breat": {
    "totals": {
      "unique_visitors": 10005,
      "visits": 10398,
      "pageviews": 12979,
      "bots": 861
    },
    "countries": {
      "FR": 6113,
      "US": 1666
    },
    "referrers": {}
  },
  "code": {
    "totals": {
      "unique_visitors": 500,
      "visits": 620,
      "pageviews": 1400,
      "bots": 80
    },
    "countries": {
      "US": 300,
      "FR": 120
    },
    "referrers": {}
  }
}

Fields

totals

totals contains the old global counters for one site.

"totals": {
  "unique_visitors": 1000,
  "visits": 1200,
  "pageviews": 3000,
  "bots": 50
}

Supported values:

Missing values are treated as 0.

countries

countries contains old page views by country.

Country codes should use two-letter ISO codes, for example FR, US, DE or GB — Brivacia normalizes the case automatically (fr and FR are treated as the same country), so you don't need to worry about getting the case exactly right if you're writing this file by hand. The Export → Legacy statistics button always produces uppercase codes, matching Brivacia's internal convention.

"countries": {
  "FR": 600,
  "US": 250,
  "DE": 100
}

referrers

referrers contains old page views by referrer domain.

"referrers": {
  "google.com": 42,
  "bing.com": 12,
  "duckduckgo.com": 5
}

To keep old search engine statistics, add search engines as referrers. Brivacia will classify them using its normal referrer rules when possible. See referrer labels for more information.

What legacy statistics affect

Legacy statistics affect only the All period.

They can be added to:

What legacy statistics do not affect

Legacy statistics do not create or change pages.

They do not affect:

This is intentional. Legacy statistics keep historical totals without bringing old page-level noise into the new Brivacia database.

Clean reset workflow

To start clean while keeping old totals:

  1. Get archives/legacy_stats.json — ideally via Export → Legacy statistics if you already have data in Brivacia (for example right after a full import), otherwise write it by hand.
  2. Back up your current Brivacia files.
  3. Remove the old SQLite database.
  4. Remove old imported archive files if they contain data you no longer want.
  5. Keep your Brivacia settings, key and legacy file.
  6. Let Brivacia create a fresh database.

Keep:

data/settings.json
data/brivacia.key
archives/legacy_stats.json

Remove or move away old imported data such as:

data/brivacia.sqlite
archives/summary.json
archives/2024-example.json
archives/2025-example.json

Brivacia will rebuild archives/summary.json automatically.

Full import or legacy statistics?

Use a full import when you really want detailed old data, including old pages.

Use legacy statistics when you want to preserve old global numbers without importing old URLs, old query strings, old page titles, old languages or old tracking mistakes.

A common workflow is actually both, in order: do a full import first, then use Export → Legacy statistics to save a clean lifetime snapshot of the result, then reset — see Clean reset workflow.

In short:

Full import = more detail, more risk of old noise.
Legacy statistics = clean reset, preserved all-time totals.

Do you find this project useful? You can support its development using the buttons in the page footer.