Custom Site Rules
Brivacia works out of the box for most websites.
If your website uses custom URLs, multilingual pages, dynamic routes, or unusual page titles, you can customize how pages appear in the dashboard by creating /includes/rules_custom.php from the provided template /includes/rules_custom.sample.php.
Getting started
- Copy:
/includes/rules_custom.sample.php
- Rename it to:
/includes/rules_custom.php
- Edit only the sections you need.
Brivacia automatically loads rules_custom.php when it exists.
Website titles vs analytics titles
Website titles and analytics titles do not always have the same purpose.
Visitors already have context from the website navigation, the page URL, and the page they came from.
For example, a documentation page may simply use Changelog because visitors already know which project they are viewing.
In an analytics dashboard, that same title may appear across many different projects and become difficult to identify.
Custom rules can add missing context and improve readability:
Website title:
Changelog
Dashboard title:
Brivacia: Changelog
This improves analytics without modifying the tracked website itself.
How it works
The file is divided into two types of sections:
General
Rules applied to all tracked websites.
Example:
$title = trim($title);
Site sections
Rules applied only to a specific website.
Example:
if ($isSite1) {
$title = str_replace(
'Old title',
'New title',
$title
);
}
$isSite1, $isSite2, $isSite3, etc. are automatically generated from the websites defined during the Wizard and/or in Settings modal.
Multiple websites
Sites are matched in the same order as Tracked sites in Settings modal.
Example — Tracked sites configured as:
Site code: main Domain: example.com
Site code: docs Domain: docs.example.com
Then:
if ($isSite1) {
// example.com
}
if ($isSite2) {
// docs.example.com
}
Available variables
Website
$isSite1
$isSite2
$isSite3
...
Boolean values indicating whether the current page belongs to a specific tracked website.
Page title
$title
Current page title displayed in the dashboard.
You may modify it directly:
$title = str_replace(
'My Website',
'',
$title
);
Page ID
$pageId
Raw page identifier without language information — this is whatever the tracking pixel sent as page (the current URL path by default, or a custom stable ID if you set one up — see connecting your website). Custom rules only change how it's displayed, not the value itself.
Example:
faq
contact
pricing
Tracked website language
$trackedWebsiteLang
Reserved for future use. rules_custom.php currently runs at the point where Brivacia resolves a page's title/URL for display, and no tracked-website language is passed into that step — so $trackedWebsiteLang is always an empty string here today, regardless of what the tracking pixel actually sent.
To act on a page's language in rules_custom.php, read it from $pageKey instead (see below), which always carries the resolved language:
$lang = pageLanguageCode($pageKey); // 'en', 'fr', 'xx' (unknown), ...
if ($isSite1 && $lang === 'en') {
$title .= ' (English)';
}
Page identifier
$pageKey
Internal page key used by Brivacia. It always starts with a 2-letter language prefix followed by :, even for a single-language website — Brivacia uses xx: when the language couldn't be determined for a given page, rather than leaving it out.
Example:
en:faq
fr:faq
ko:faq
xx:faq
Use pageLanguageCode($pageKey) to read just the language part (e.g. en), and brivaciaRawPageKey($pageKey) to read just the identifier part (e.g. faq).
Page URL
$pageUrl
URL displayed in the dashboard.
Example:
$pageUrl = str_replace(
'/old-url',
'/new-url',
$pageUrl
);
Original URL
$url
Raw URL received from the tracking pixel before any customization.
Examples
Rename page titles
if ($isSite1) {
$title = str_replace(
'FAQ – My Website',
'FAQ',
$title
);
}
Replace URLs
if ($isSite1) {
$pageUrl = str_replace(
'/old-page',
'/new-page',
$pageUrl
);
}
Multilingual websites
if ($isSite1 && pageLanguageCode($pageKey) === 'en') {
$title .= ' (English)';
}
Advanced variables
Most users only need:
$isSite1
$title
$pageId
$pageKey
$url
$pageUrl
Advanced users may also access:
$site
$site1
$site2
$site3
...
$trackedWebsiteLang
$resolved
These variables are available for advanced custom rules but are not required for normal usage.
Notes
rules_custom.phpis never modified by Brivacia updates.- Only modify the variables you need.
- You can create as many site sections as required.
- If
rules_custom.phpdoes not exist, Brivacia uses its default behavior. - All custom rule changes are applied only inside the Brivacia dashboard and never modify your website.
Do you find this project useful? You can support its development using the buttons in the page footer.
breat.fr