Visit AnalyticsUser Manual Visit Visit Analytics →
Reference and help

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

FileWhat it does
track.phpThe include that goes into your website.
beacon.phpReceives the confirmation of the human verification script.
lib/core.phpSettings, dates, IP handling, country lookup and the XML reading and writing.
lib/detect.phpBrowser and system detection, bot lists, spam domains, scanner patterns and traffic source lists.
lib/tracker.phpWhat happens during a page load.
lib/report.phpCalculates the statistics from the XML files.
admin/index.phpThe admin panel: login, menu and the page loader.
admin/pages/*.phpOne file per report page.
admin/assets/app.cssThe stylesheet. Colors are variables in the first lines.
lang/en.phpAll 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

  1. Create admin/pages/myreport.php. Start it with if (!defined('VA_DIR')) exit; and call $R = va_report($from, $to); to get all statistics of the selected period.
  2. Add 'myreport' => 'file' to the $pages list and to $groups at the top of admin/index.php.
  3. Add 'menu_myreport' => 'My report' to lang/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