How does Matomo Analytics work?
So as most of analytics tools Matomo works with:
<!-- Matomo -->
var _paq = window._paq || ;
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script');
<!-- End Matomo Code -->
As you can see from the code above, there is a file named matomo.php, this file is here in order to send all the data that the matomo.js tracker collected about the internet user when this script has been loaded.
About the cookies
Cookies are here in order to store values for Matomo to be able to record data with more consistency.
By default, Matomo is storing 3 cookies on the browser of the internet user:
- _pk_id: to store the visitor id of the internet user.
- _pk_se: to store the visit/session of the internet user.
- _pk_ref: to store the referrer of the internet, so by which communication channel she/he came.
Let's imagine a scenario in which the cookie _pk_se cannot be set (for example an internet user has a browser extension blocking this cookie), it would mean that every interaction recorded by this given internet user will be consider as a new visit. You could then imagine how fake your data are going to be.
If the _pk_id could not be set, it would mean that the count of visitors will be totally biased too, not though that Matomo has a mechanism named fingerprinting in order to identify the same internet user if they are blocking cookies. It is using a combination of all the attributes of the internet user in order to attribute her/him a given id.
You can easily check the different caracteristics of your cookies within your browser.
How to check that the Matomo tracking code is working and that cookies are well set?
As we just saw, Matomo is working thanks to a tracking code which is sending the data to the Matomo server + setting cookies on the internet user browser.
As a result we can check all that within our Firefox browser by looking at the HTTP requests sent + the cookies. You will find the details of HTTP requests within the network tab and the cookies within the cookies tab.