JS-Tracking, php-Tracking, LogFile import or image tracking - which method should I choose and why

Disclaimer: this is a draft needing revision, no guarantees on correctness at this stage!

This article shall eventually cover the differences between the available ways of collecting visitor data with Matomo, to serve as an entry point to integrating Matomo in the way that matches your demands.

It is generally possible to use a mix of methods, but before you start implementing Matomo,
you might want to get familiar with eachs methods benefits and limitations.

Let’s start by taking a look at when the data collection takes place, depending on the tracking method:


Note that the JS-tracking allows collection of extra data once the Javascript executes - at the “price” of firing a lot later than the other methods.

This leads to different data being collected by the different methods, as displayed in below chart:

Scope of data collection depending on Matomo tracking method ServerLogs import Matomo php-tracking Matomo Img-tracking Matomo JS-tracking combined Matomo JS + Img tracking
Known crawlers (googlebot, FB-crawler etc) optional
ignored by default
optional
ignored by default
:cross: :cross: :cross:
Unknown crawlers / bots :tick: :tick: :cross: :cross: :cross:
Visits using AdBlocker :tick: :tick: :cross: :cross: :cross:
Visits with DNT enabled :tick: optional optional optional optional
Visits without Javascript :tick: :tick: :tick: :cross: :tick:
Basic data from header request :tick: :tick: :tick: :tick: :tick:
Additional browser data from JS environment :cross: :cross: :cross: :tick: :tick:

Comment:
The large data collections of the Server Logging & php-tracking will give you better insight in the servers load situation and the kinds of unknown bot hits your website receives,
while the smaller but enriched data collection of the JS tracking will let you get a quicker picture of what the real visitors are doing on your site, and what kinds of devices they are using.

Pros and Cons ServerLogs import Matomo php-tracking Matomo Img-tracking Matomo JS-tracking combined Matomo JS + Img tracking
“Live” real-time reports in Matomo :cross: :tick: :tick: :tick: :tick:
Works with static html pages :tick: :cross: :tick: :tick: :tick:
Works with SinglePageApplications :cross: :tick: :tick: :tick: :tick:
Works in emails :cross: :cross: :tick: :cross: :cross:
Can trace on-interface interactions that do not trigger page navigation :cross: :cross: :cross: :tick: :tick:
Can evaluate content impressions/visibility in viewport on responsive sites :cross: :cross: :cross: :tick: :tick:
Can be easily configured in Matomo to meet EU data privacy standards :cross: :tick: :tick: :tick: :tick:
Can be enhanced with custom variables :cross: :tick: :tick: :tick: :tick:
Impact on perceived page load time none delay as php is executed none none none
Added web traffic on first visit none none ~220 bytes (one request) 22kb compressed piwik.js + 2nd request to transfer data 22kb compressed piwik.js + 2nd request to transfer data
Easy to implement when tracking sites across several servers :cross: :tick: :tick: :tick: :tick:
Sets a Cookie :cross: :tick: :tick: :tick: :tick:
Track server error :tick: :tick:
(manually)
:cross: :cross: :cross:

The discussion about this comparison can be found here: