October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Matomo Log Analytics: How to Import Server Logs into Matomo

Matomo Log Analytics is a Python importer for server access logs. Here are the requirements, the command, Cloud token settings and how to avoid duplicate imports.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Matomo Log Analytics is a Python command-line importer. It reads your web server’s access logs and sends each line to Matomo as a tracked request. You run it with import_logs.py --url=your Matomo URL --idsite=ID logfile. The one thing to get right first is duplication: Matomo does not detect repeat imports, so a log file imported twice is counted twice.

What you need before importing

According to Matomo’s requirements page, Log Analytics works with Matomo Cloud, Matomo On-Premise and Matomo for WordPress. Matomo lists these requirements:

As an Amazon Associate I earn from qualifying purchases.

  • SSH, or another way to run scripts on a server.
  • Python 3.5 or newer. Matomo’s page states “Python 3.5 or newer required.” Check the README that ships with your copy of the script, because requirements can change.
  • One or more log files whose lines are in date order.

Log fields that improve reports

Matomo recommends logs that contain the User-Agent, the referrer URL and the full request URL including the hostname. Logs without these fields can still be imported. Some reports may then be missing or less accurate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Geolocation

Access logs have no browser-language field to fall back on, so country and city reports depend on IP geolocation. On-Premise installations need geolocation set up for accurate results. Matomo says it handles this automatically for Cloud and Matomo for WordPress.

Create a dedicated website in Matomo first

Create a separate Matomo website for imported logs and note its site ID. This matters most if you also use the JavaScript tracker or the Tracking API. Matomo’s FAQ says the methods can coexist if each records to its own website. If you import logs into the same website the JavaScript tracker feeds, the counts can be doubled.

How do I import server logs into Matomo?

1. Locate the script

On-Premise installations include it at misc/log-analytics/import_logs.py. Matomo Cloud and Matomo for WordPress users download it from the GitHub repository that Matomo links in its documentation. See Matomo’s guide to running the importer with default options.

2. Run it against a test site

The documented required parameter is --url, the base URL of your Matomo. After that, list one or more log files. A minimal command looks like this:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python3 /path/to/matomo/misc/log-analytics/import_logs.py 
  --url=https://analytics.example.com 
  --idsite=1234 
  /path/to/access.log

--idsite picks the destination Matomo website. It is not strictly required for every setup, but you should set it so data lands where you expect. Not every flag is needed.

3. Add authentication if the script runs elsewhere

If the importer runs on a different server from Matomo, add --token-auth with an API authentication token. For Matomo Cloud, the Cloud FAQ says Log Analytics can be used and tells you to untick “Only allow secure requests” when you create the token for this purpose.

4. Choose the log format and options

The importer usually detects the format on its own. To force one, use --log-format-name. The FAQ lists these names: common, common_vhost, ncsa_extended, common_complete, w3c_extended, amazon_cloudfront, iis, shoutcast, s3, icecast2, elb, nginx_json and ovh. Optional flags exist for recording HTTP errors, redirects, static files and bots. Use --debug when troubleshooting.

The format list and the options depend on the importer version. Run the script with --help and read the README that came with your copy for the current set.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Check the results

Open the test website’s reports in Matomo and confirm that visits, pages and dates look right. Only then import into the real destination.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Avoiding duplicate data

Matomo states that the importer has no check for redundant data. Importing the same material again can double or triple the numbers without any warning. Keep a record of which files you have imported. Test on a test site first. If a rotated log overlaps one you already loaded, do not import the overlap again.

Troubleshooting

  • Zero requests imported with no error: check file permissions. Matomo suggests checking which user runs the script. For routine imports, use a specific user rather than running as superuser.
  • Missing or odd reports: check whether your log format includes User-Agent, referrer and full URL with hostname.
  • Wrong format detected: set --log-format-name explicitly and add --debug.
  • Out-of-order dates: sort or combine logs chronologically before importing, since the importer expects date-ordered lines.

Choosing between log import, JavaScript and the Tracking API

All three methods can feed Matomo. Think about these questions when picking one:

  • Can you change the site’s code to add a tracker?
  • Do your logs contain the fields behind the reports you want?
  • Will you run more than one method? If so, each needs its own Matomo website to avoid duplicate counts.
  • Which deployment do you use? Cloud and WordPress handle geolocation for you. On-Premise needs it configured.

Matomo’s documentation does not give a feature-by-feature comparison of what each method can report, so this article does not make one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can I use Matomo Log Analytics with Matomo Cloud?

Yes. Matomo’s Cloud FAQ says Log Analytics can be used with Matomo Cloud. Download the script from GitHub and run it with a token.

Can I use server log analytics and the Matomo JavaScript tracker together?

Yes, but only if each method records to a separate Matomo website. The same website would produce double counts.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.