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:
const BRIVACIA_SITES = [
'main' => 'example.com',
'docs' => '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.
Example:
faq
contact
pricing
Tracked website language
$trackedWebsiteLang
Language sent by the tracked website.
Examples:
fr
en
es
ko
en-US
This value is stored as-is by Brivacia. It may be a short code like en or a regional code like en-US, depending on your tracked website.
This is not related to the Brivacia dashboard language.
Page identifier
$pageKey
Internal page key used by Brivacia.
For multilingual websites, the tracked website language may be included in the identifier. This allows Brivacia to distinguish and track each language version separately.
Example:
faq
contact
pricing
en:faq
fr:faq
ko: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 && $trackedWebsiteLang === 'en') {
$title .= ' (English)';
}
Advanced variables
Most users only need:
$isSite1
$title
$pageId
$trackedWebsiteLang
$pageKey
$url
$pageUrl
Advanced users may also access:
$site
$site1
$site2
$site3
...
$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