Customizing VisitAnalytics: edit bot lists, colors and add reports
There are no frameworks and no classes: every file is a handful of readable PHP functions. Anyone who knows basic PHP can adapt it.
The files
| File | What it does |
|---|---|
track.php | The include that goes into your website. |
beacon.php | Receives the confirmation of the human verification script. |
lib/core.php | Settings, dates, IP handling, country lookup and the XML reading and writing. |
lib/detect.php | Browser and system detection, bot lists, spam domains, scanner patterns and traffic source lists. |
lib/tracker.php | What happens during a page load. |
lib/report.php | Calculates the statistics from the XML files. |
admin/index.php | The admin panel: login, menu and the page loader. |
admin/pages/*.php | One file per report page. |
admin/assets/app.css | The stylesheet. Colors are variables in the first lines. |
lang/en.php | All admin texts. |
Common changes
Add a robot or a spam domain
Open lib/detect.php. va_bot_patterns() contains one line per robot type with names separated by |; add your word. va_spam_referrers() lists spam domains.
Add a search engine, social network or AI assistant
In the same file, va_source_rules() maps domains to names, for example 'chatgpt.com' => 'ChatGPT' in the ai group.
Change the colors of the admin panel
Open admin/assets/app.css. The first lines define --primary, --side and other colors for light and dark mode.
Change default settings
va_default_config() in lib/core.php lists every setting with its default value.
Add a new report page
- Create
admin/pages/myreport.php. Start it withif (!defined('VA_DIR')) exit;and call$R = va_report($from, $to);to get all statistics of the selected period. - Add
'myreport' => 'file'to the$pageslist and to$groupsat the top ofadmin/index.php. - Add
'menu_myreport' => 'My report'tolang/en.php.
Refresh the country database
Download the free DB-IP "IP to Country Lite" CSV and run php tools/build_geo.php dbip-country-lite-YYYY-MM.csv. Keep the "IP Geolocation by DB-IP" credit in the footer.
When you update VisitAnalytics, your changes in program files are overwritten. Keep a note of what you changed, or keep a copy of the modified files.
Last updated