breat.fr

Legacy statistics

Brivacia can keep your old analytics history 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 numbers to be included in the statistics.

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

There are two modes:

Both modes live in the same file and can be mixed per site — see JSON format below.

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. Two buttons are available under Export:

Either one 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). Use the detailed export if you want Today/Week/Month/Year to already show meaningful data right after the reset; use the totals export if you only care about the lifetime numbers on All, or if the resulting file size matters (a detailed export can get large after a year or more of history — see Fields).

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 totals format described below. There's no realistic way to hand-write a detailed, day-by-day file, since you'd need the exact date of every old day — that mode only makes sense for the auto-generated export.

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).

Which dashboard periods the file affects depends on the mode used per site — see What legacy statistics affect.

JSON format

The root keys are Brivacia site codes. Each site is independent, and can use either mode — nothing stops one site from using totals while another uses the detailed format in the same file.

Totals mode

A site entry with a totals object (and, optionally, countries/referrers as simple maps) is read as one lifetime total. This is the format used by the hand-written path, and by the Legacy statistics (totals) export.

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
    }
  }
}

Detailed mode

A site entry with a non-empty days array (instead of a totals object) is read as day-by-day history. Every row needs a day (format YYYY-MM-DD) — rows without one are ignored. This is the format produced by the Legacy statistics (detailed) export; it isn't meant to be written by hand.

{
  "breat": {
    "days": [
      { "day": "2024-06-24", "unique_visitors": 2, "visits": 2, "pageviews": 2, "bots": 0 },
      { "day": "2024-06-25", "unique_visitors": 5, "visits": 6, "pageviews": 9, "bots": 1 }
    ],
    "countries": [
      { "day": "2024-06-24", "country": "FR", "views": 1 },
      { "day": "2024-06-25", "country": "US", "views": 2 }
    ],
    "referrers": [
      { "day": "2024-06-24", "referrer": "google.com", "views": 1 }
    ]
  }
}

There is no pages section in either mode, by design — see Why this exists.

Example mixing both modes in the same file:

{
  "breat": {
    "days": [
      { "day": "2024-06-24", "unique_visitors": 2, "visits": 2, "pageviews": 2, "bots": 0 }
    ],
    "countries": [
      { "day": "2024-06-24", "country": "FR", "views": 1 }
    ],
    "referrers": []
  },
  "code": {
    "totals": {
      "unique_visitors": 500,
      "visits": 620,
      "pageviews": 1400,
      "bots": 80
    },
    "countries": {
      "US": 300,
      "FR": 120
    },
    "referrers": {}
  }
}

Fields

totals (totals mode only)

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.

days (detailed mode only)

days contains one row per day, in the same shape as totals plus a day date.

"days": [
  { "day": "2025-03-01", "unique_visitors": 12, "visits": 14, "pageviews": 30, "bots": 3 }
]

Rows with an invalid or missing day are skipped. Missing counters are treated as 0, same as totals mode.

A word of caution on file size: this array has one row per day the site was tracked, so a site with a couple of years of history can easily produce a few hundred rows here alone — combined with countries/referrers below, a multi-year, multi-country detailed export can reach several thousand lines. That's normal, and Brivacia handles it fine, but it's the trade-off for having Today/Week/Month/Year populated from day one — see Generating the file if you'd rather keep the file small.

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 buttons always produce uppercase codes, matching Brivacia's internal convention.

In totals mode, it's a map of country → views:

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

In detailed mode, it's an array of one row per day and country instead:

"countries": [
  { "day": "2025-03-01", "country": "FR", "views": 8 },
  { "day": "2025-03-01", "country": "US", "views": 4 }
]

referrers

referrers contains old page views by referrer domain.

In totals mode, it's a map of referrer → views:

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

In detailed mode, it's an array of one row per day and referrer instead:

"referrers": [
  { "day": "2025-03-01", "referrer": "google.com", "views": 3 }
]

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

What Brivacia shows depends on the mode used for that site's entry:

In both modes, legacy data can be added to:

What legacy statistics do not affect

Legacy statistics do not create or change pages, regardless of mode.

They do not affect:

This is intentional. Legacy statistics keep historical numbers without bringing old page-level noise into the new Brivacia database — that's true whether you use totals or detailed mode, the difference between the two is only about when the numbers show up (All only, or every period), never about pages.

Clean reset workflow

To start clean while keeping old numbers:

  1. Get archives/legacy_stats.json — ideally via Export → Legacy statistics (totals or detailed) if you already have data in Brivacia (for example right after a full import), otherwise write it by hand (totals mode only). Pick detailed if you want Today/Week/Month/Year to already show data after the reset, totals if you only care about All or want the smaller file.
  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 numbers without importing old URLs, old query strings, old page titles, old languages or old tracking mistakes — pick detailed mode if you also want those numbers spread across Today/Week/Month/Year instead of just All.

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

In short:

Full import = more detail, more risk of old noise.
Legacy statistics (totals) = clean reset, all-time totals only.
Legacy statistics (detailed) = clean reset, all-time totals AND populated Today/Week/Month/Year.

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