Data Whimsy
  • Home
  • What is Matomo
  • Contact
  • Custom Reports
  • Connect Matomo to other software
  • CLI API etc
  • Matomo Tag Manager Simple Guide
  • Lyn Only
  • Troubleshooting + Deploying Matomo
  • Weird Data
  • Why is data in Matomo giving different numbers than Google Analytics
  • The Dashboard
  • Moving the Data
  • Book Club Forum

Without the dashboard

The top slot of your browser can send requests to Tracking API & Reporting API
The command line of your browser can accept direct Matomo input (e.g. the PHP ./console command).
On this page are a variety of things you can do without ever touching the visual dashboard (Matomo GUI)

Ecommerce methods in Matomo (Javascript)

11/7/2024

0 Comments

 
Question:
In Matomo, which methods are available in Ecommerce to pass information to Matomo, from the data layer of the browser?

Answer:
In Matomo, to track Ecommerce data from the data layer of the browser, several JavaScript methods are available within the Matomo tracking API. These methods enable you to pass product and order-related information efficiently. Here's an overview of the key methods used for Ecommerce tracking:

### 1. **Ecommerce Tracking Methods**
   - **`trackEcommerceOrder(orderId, grandTotal, subTotal, tax, shipping, discount)`**
     - This method is used to track an order after a user completes a purchase. You should call this method with details such as the order ID, total amount, and any applicable taxes, shipping, and discounts.
     - **Parameters:**
       - `orderId`: Unique identifier for the order.
       - `grandTotal`: The total amount of the order (including tax, shipping, etc.).
       - `subTotal`: (Optional) Total value of the items in the order, excluding tax and shipping.
       - `tax`: (Optional) Total tax for the order.
       - `shipping`: (Optional) Shipping cost for the order.
       - `discount`: (Optional) Discount applied to the order.

   - **`addEcommerceItem(sku, name, category, price, quantity)`**
     - This method is used to add items to the cart or an order. Each item added is associated with details such as SKU, product name, category, price, and quantity.
     - **Parameters:**
       - `sku`: The unique identifier for the product (e.g., product code).
       - `name`: (Optional) The name of the product.
       - `category`: (Optional) Category name or hierarchy (e.g., "Clothing > Men > Shirts").
       - `price`: (Optional) Price of the product.
       - `quantity`: (Optional) Quantity of the product being purchased.

   - **`trackEcommerceCartUpdate(grandTotal)`**
     - This method is used to update the cart's total value. Call this whenever the cart's content changes (e.g., adding or removing products).
     - **Parameters:**
       - `grandTotal`: The updated total amount of the cart.

### 2. **Implementation Tips**
   - **Data Layer Integration**: To use these methods with data from a data layer (like in a tag management system), you typically access the data layer variables and pass the values to these methods.
   - **Order of Execution**: Ensure that `addEcommerceItem` is called before `trackEcommerceOrder` to associate all items with the order.
   - **Asynchronous Loading**: If using Matomo asynchronously, make sure that the data layer information is loaded and accessible before calling these methods.

### 3. **Example Usage**
```javascript
// Example: Tracking a purchase with multiple items
_paq.push(['addEcommerceItem',
    "12345", // SKU
    "Running Shoes", // Product name
    "Sports > Running", // Category
    99.95, // Price
    2 // Quantity
]);

_paq.push(['addEcommerceItem',
    "67890", // SKU
    "Running Shorts", // Product name
    "Sports > Running", // Category
    49.95, // Price
    1 // Quantity
]);

// Track the order
_paq.push(['trackEcommerceOrder',
    "ORDER123", // Order ID
    249.85, // Grand Total
    199.85, // Sub Total
    20.00, // Tax
    30.00, // Shipping
    0.00 // Discount
]);
```

These methods should be called in sequence based on the Ecommerce events occurring on your website, like adding items to the cart or completing a purchase.h
h
h

0 Comments

Examples of Matomo's database table matomo_archive_invalidations

11/4/2024

0 Comments

 
How does Matomo keep track of what to process?
The core:archive looks for invalidations in the database table called matomo_archive_invalidations.

Four sequential screenshots of the invalidations table in the MySQL database.
1. The table is empty becuase I did:
   mysql> TRUNCATE  matomo_archive_invalidations;
   mysql> SELECT count(*) FROM  matomo_archive_invalidations;
2. Then I told Matomo that all the reports are stale for today and yesterday.
This second screenshot is after this CLI command
   CLI: sudo su www-data -s /bin/bash -c  "php /var/www/littlefurnace.com/matomo/console core:invalidate-report-data --sites=1,2  --dates="2024-11-03",today --periods=day,week,month"
    mysql> SELECT count(*) FROM  matomo_archive_invalidations;
3. Then I ran the archiver, telling it to not calculate the archiving of any segments.
The syntax in Matomo for archiving WITHOUT doing segments is like this:
$ sudo su www-data -s /bin/bash -c  "php  -d memory_limit=2G   /var/www/littlefurnace.com/matomo/console core:archive --skip-all-segments --force-idsites=1,2"
4. The fourth screenshot is of the database after archiving the segments using the following command, similar to the command in 3:
  $ sudo su www-data -s /bin/bash -c  "php  -d memory_limit=2G   /var/www/littlefurnace.com/matomo/console core:archive  --force-idsites=1,2"


Picture
Picture
Picture
Picture

What happens in the matomo_archive_invalidations table when you invalidate?

When you do one simple command, invalidate a year, for one site (not any days nor months), what is created in the table is actually a series of rows, presumably each one a different recipe which needs to be performed on your one site, for the year.  Recall that Matomo builds the data of a YEAR by adding up the reports for the individual DAYS.

Run this in the CLI
sudo su www-data -s /bin/bash -c  "php /var/www/littlefurnace.com/matomo/console core:invalidate-report-data --sites=1  --periods=year --dates='2024-11-02','2024-11-02'"

You'll create these lines in the invalidations queue (which is stored in the db as matomo_archive_invalidations

Picture
0 Comments

Curl examples with POST for Matomo

8/30/2024

0 Comments

 

curl -X POST "https://littlefurnace.com/matomo/index.php?module=API&method=MultiSites.getOne&idSite=2&period=range&date=2024-06-28,2024-08-28&format=JSON" -H "Content-Type: application/x-www-form-urlencoded" --data 'token_auth=???????????????'
curl -X POST "https://littlefurnace.com/matomo/index.php?module=API&method=MultiSites.getAll&period=year&date=yesterday&format=JSON" -H "Content-Type: application/x-www-form-urlencoded" --data 'token_auth=REDACTED'
curl -X POST "https://littlefurnace.com/matomo/index.php?module=API&method=MultiSites.getAll&period=year&date=yesterday&format=JSON" -H "Content-Type: application/x-www-form-urlencoded" --data 'token_auth=???????????????'
​
0 Comments

Printing the processes with PS

8/5/2024

0 Comments

 
htop     # Makes a dynamic dashboard but is not easy to log or print out from

ps -aux | awk '{ print $1, $3 }'  # good for printing/logging

ps -aux | awk '{ $11 = substr($11, 1, 16); print }' inputfile
ps -aux | awk '{ $11 = substr($11, 1, 16); printf "%-15s%-15s%-15s%-15s%-15s%-15s%-15s%-15s%-15s%-15s%-15s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11 }' | head
ps -aux | awk '{ $11 = substr($11, 1, 16); printf "%-15s%15s%5s%5s%11s%5s%5s%8s%8s%8s%10s\n", $11, $2, $3, $4, $5, $6, $7, $8, $9, $10, $1 }' | sort -nk +5 | grep php
echo "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND" ; ps -aux | sort -nrk +5 | grep php > PATH/TOYOUR/FILE.txt
0 Comments

Examples of SED, GREP, RegEx

5/24/2024

0 Comments

 
Cookbook of command line regex examples for sed and grep that worked for me.

1
$ sed -E s/[0-9][A-Za-z]/foooooooo/g  filename.txt

2
New line can be done by piping from sed -> tr
$ echo "123." | sed -E 's/([[:digit:]]*)\./\1|next line/' | tr '|' '\n'

3
Example with "any digit", capture group, and newline

$ echo "123z" | sed -E 's/([[:digit:]]*)z/\1\n next line/'

4
Within  a  bracket  expression, the name of a character class enclosed in "[:" and ":]" stands for the list of all characters belonging to that class.  Standard character class names are:

              alnum   digit   punct
              alpha   graph   space
              blank   lower   upper
              cntrl   print   xdigit

5
How to locate logs
sudo find / -name 'apache2' | grep log
sudo find / -name 'matomo' | grep log | sed /blog/d | sed /sql/d

How to find the fullness of the log
df -h {PATH.TO.LOG}
df -hi {PATH.TO.LOG}



0 Comments

Gallery of typical tracking requests, as seen in devtools.

5/1/2024

0 Comments

 
Are you monitoring a website with Matomo? Open a page from your website in a browser, then click browser>>devtools.  The network tab (browser>>devtools>>network) will show Matomo's actual tracking requests.  

A fun extension which also shows this is Chrome Tagbirds. I'm paranoid of browser extensions (because of security), so I only use this on an isolated machine which never runs any of my password secured applications.

I have fomatted these requests by adding linebreaks.

#1
From a single page, send http requests to two Matomo instances at the same time 
As described at https://matomo.org/faq/how-to/how-do-i-send-tracking-requests-to-two-or-more-matomo-servers/ 

The Javascript Tracker Code
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//littlefurnace.com/matomo/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '2']);
var secondaryTracker = 'https://tatll.matomo.cloud/matomo.php';
var secondaryWebsiteId = '6';
// Also send all of the tracking data to the new Matomo server
_paq.push(['addTracker', secondaryTracker, secondaryWebsiteId]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->

Request One

POST https://tatll.matomo.cloud/matomo.php?
action_name=pikL&
idsite=6&
rec=1&
r=357217&
h=11&
m=36&
s=48&
url=https://pikl.us/&
_id=8e2306f5d48d5003&
_idn=0&
send_image=0&
_refts=1714581408&
_ref=https://github.com/atom-box/bpikl&
pv_id=jVb0xW&
fa_pv=1&
fa_fp[0][fa_vid]=Tl9OUd&
fa_fp[0][fa_name]=urlEnterer&
fa_fp[0][fa_fv]=1&
pf_net=0&
pf_srv=266&
pf_tfr=41&
uadata={}&
pdf=1&
qt=0&
realp=0&
wma=0&
fla=0&
java=0&
ag=0&
cookie=1&
res=1920x1080

Request Two
POST https://littlefurnace.com/matomo/matomo.php?
action_name=pikL&
idsite=2&
rec=1&
r=473795&
h=11&
m=36&
s=48&
url=https://pikl.us/&
_id=03690a3479d38e0e&
_idn=0&
send_image=0&
_refts=1714581408&POST https://littlefurnace.com/matomo/matomo.php?
action_name=pikL&
idsite=2&
rec=1&
r=473795&
h=11&
m=36&
s=48&
url=https://pikl.us/&
_id=03690a3479d38e0e&
_idn=0&
send_image=0&
_refts=1714581408&
_ref=https://github.com/atom-box/bpikl&
pv_id=zC90X6&
fa_pv=1&
fa_fp[0][fa_vid]=Tl9OUd&
fa_fp[0][fa_name]=urlEnterer&
fa_fp[0][fa_fv]=1&
pf_net=0&
pf_srv=266&
pf_tfr=41&
uadata={}&
pdf=1&
qt=0&
realp=0&
wma=0&
fla=0&
java=0&
ag=0&
cookie=1&
res=1920x1080POST https://littlefurnace.com/matomo/matomo.php?
action_name=pikL&
idsite=2&
rec=1&
r=473795&
h=11&
m=36&
s=48&
url=https://pikl.us/&
_id=03690a3479d38e0e&
_idn=0&
send_image=0&
_refts=1714581408&
_ref=https://github.com/atom-box/bpikl&
pv_id=zC90X6&
fa_pv=1&
fa_fp[0][fa_vid]=Tl9OUd&
fa_fp[0][fa_name]=urlEnterer&
fa_fp[0][fa_fv]=1&
pf_net=0&
pf_srv=266&
pf_tfr=41&
uadata={}&
pdf=1&
qt=0&
realp=0&
wma=0&
fla=0&
java=0&
ag=0&
cookie=1&
res=1920x1080
_ref=https://github.com/atom-box/bpikl&
pv_id=zC90X6&
fa_pv=1&
fa_fp[0][fa_vid]=Tl9OUd&
fa_fp[0][fa_name]=urlEnterer&
fa_fp[0][fa_fv]=1&
pf_net=0&
pf_srv=266&
pf_tfr=41&
uadata={}&
pdf=1&
qt=0&
realp=0&
wma=0&
fla=0&
java=0&
ag=0&
cookie=1&
res=1920x1080


#2
A heatmaps/screenrecording
0 Comments

Examples in Matomo On Premises of core:invalidate-report-data & core:archive

3/20/2024

0 Comments

 
PART ONE
This part is optional. 
If you don

't need to invalidate reports, skip to Part Two

sudo su www-data -s /bin/bash -c  "php /var/www/littlefurnace.com/matomo/console core:invalidate-report-data"

Matomo parameters are not well-standardized. Here are examples of the syntax for all of the invalidate-report-data parameters I have used this year:
--dates=2024-04-20,today   <---- contrast this to the force-date-range used above
--dates=2024-08-04,2024-08-05
--dates=yesterday 
--periods=day,week
--segment=33
--sites=1,5

Putting it all together, you could run invalidation like this if you wanted to
sudo su www-data -s /bin/bash -c  "php /var/www/littlefurnace.com/matomo/console core:invalidate-report-data --dates=2024-08-04,2024-08-05 --periods=year --segment=33 --sites=1,5"




PART TWO
These are self explanatory hopefully.

If you are in the directory on your machine where the matomo files are, you might be able to just run this, if you are signed in as the right user:
console core:archive

The owner is usually www-data or apache so I usually run it like this:
sudo su www-data -s /bin/bash -c  "php -d memory_limit=3G /var/www/littlefurnace.com/matomo/console core:archive"

Here are examples of the syntax all of the parameters I have used this year:
--concurrent-archivers=1 <---- often won't work; minimum of 2, on many systems
--concurrent-archivers=5
--concurrent-requests-per-website=1
--concurrent-requests-per-website=3
--disable-scheduled-tasks
--force-date-last-n=220
--force-date-range="2023-01-01",today
--force-date-range=2023-09-01
--force-date-range=2023-09-01,2023-09-01
--force-date-range=yesterday,today
--force-idsegments=12
--force-idsites=2,3,11
--force-sites=2
--skip-all-segments
--vvv

I have never run all at the same time, but you could put most of that together and run the following. (I left out the two segment options which would contradict each other if run at the same time, although in that case, the last parameter entered would possibly be the boss ... later parameters take priority over earlier ones usually.)

sudo su www-data -s /bin/bash -c  "php -d memory_limit=6G /var/www/littlefurnace.com/matomo/console core:archive --concurrent-archivers=2 --concurrent-requests-per-website=3 --disable-scheduled-tasks --force-date-last-n=220 --force-idsites=2,3,11 --skip-all-segments --vvv"

​
PART THREE
My personal Matomo is running on a underresourced machine: one CPU, 4G of RAM. So I get to see all of the error messages, as follows.
sudo su www-data -s /bin/bash -c  "php ./console core:archive --force-idsites=1  --force-date-last-n=20"
If you run core:invalidate-report-data and then run the above command, twice in rapid succession, nothing much is done the second time. Each step took 3 seconds. 

sudo su www-data -s /bin/bash -c  "php ./console core:archive --force-idsites=2  --force-date-last-n=1"
Crashed ("unserialization error" and " Warning - shell_exec(): Unable to execute 'ps x 2>/dev/null" and "Unable to execute 'ps aux'"). Half of these mentioned a segment.
sudo su www-data -s /bin/bash -c  "php -d memory_limit=9G  /var/www/littlefurnace.com/matomo/console  core:archive   --concurrent-requests-per-website=1 --concurrent-archivers=3 --skip-all-segments --force-idsites=2"
Succeeded.
Ran all of the Custom Reports, back til the beginning of time for the new CR I authored recently.
sudo su www-data -s /bin/bash -c  "php -d memory_limit=9G  /var/www/littlefurnace.com/matomo/console  core:archive   --concurrent-requests-per-website=1 --concurrent-archivers=3  --force-idsites=2"
Succeeded.
I think the segments worked because I had already run all the basic reports.

PART FOUR
Digging into the SQL database, to audit what is going on with your archiver invalidations.

Your Matomo interface should show hollow points when data is either incomplete (like for today, because today is still in flux IRL) or because the period was invalidated but has not succesfully executed in the core:archive process. 

Will hollow data points persist in the evolution graph after everything is archived? No. Once archiving has recreated the reports both the tooltip ("invalidated") and the hollowness should go away.

How does Matomo know to make a hollow data point in a graph? If
name = "done" && value = 4 is stored in the archive_numeric table, it will still be shown as invalidated in a graph. The archive_invalidations table has no role in that visualization.

PART FIVE 

You can keep track, in your SQL database what has been invalidated.  For example here is some output from my terminal, when there are no invalid reports, and then after I have manually labeled some reports as invalid.

mysql> SELECT * FROM matomo_archive_invalidations;
Empty set (0.00 sec)
$ sudo su www-data -s /bin/bash -c "php /var/www/littlefurnace.com/matomo/console core:invalidate-report-data --sites=1 --dates=2025-04-15"
[sudo] password for evan:
INFO [2025-05-14 19:15:05] 3886 Invalidating day periods in 2025-04-15 for site = [ 1 ], segment = [ ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating day periods in 2025-04-15 for site = [ 1 ], segment = [ visitIp!=91.90.123.187 ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating day periods in 2025-04-15 for site = [ 1 ], segment = [ countryName==China,countryName==taiwan,countryName==Russia ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating week periods in 2025-04-15 for site = [ 1 ], segment = [ ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating week periods in 2025-04-15 for site = [ 1 ], segment = [ visitIp!=91.90.123.187 ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating week periods in 2025-04-15 for site = [ 1 ], segment = [ countryName==China,countryName==taiwan,countryName==Russia ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating month periods in 2025-04-15 for site = [ 1 ], segment = [ ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating month periods in 2025-04-15 for site = [ 1 ], segment = [ visitIp!=91.90.123.187 ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating month periods in 2025-04-15 for site = [ 1 ], segment = [ countryName==China,countryName==taiwan,countryName==Russia ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating year periods in 2025-04-15 for site = [ 1 ], segment = [ ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating year periods in 2025-04-15 for site = [ 1 ], segment = [ visitIp!=91.90.123.187 ]...
INFO [2025-05-14 19:15:05] 3886 Invalidating year periods in 2025-04-15 for site = [ 1 ], segment = [ countryName==China,countryName==taiwan,countryName==Russia ]...


mysql> SELECT * FROM matomo_archive_invalidations ; +----------------+-----------+--------------------------------------+--------+------------+------------+--------+---------------------+------------+--------+--------+-----------------+------------+
| idinvalidation | idarchive | name | idsite | date1 | date2 | period | ts_invalidated | ts_started | status | report | processing_host | process_id |
+----------------+-----------+--------------------------------------+--------+------------+------------+--------+---------------------+------------+--------+--------+-----------------+------------+
| 38300 | NULL | done | 1 | 2025-04-15 | 2025-04-15 | 1 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38301 | NULL | done | 1 | 2025-04-14 | 2025-04-20 | 2 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38302 | 414 | done | 1 | 2025-04-01 | 2025-04-30 | 3 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38303 | 8258 | done | 1 | 2025-01-01 | 2025-12-31 | 4 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38304 | NULL | donec1f9075b020fe8e4a5e7ebae74c38e76 | 1 | 2025-04-15 | 2025-04-15 | 1 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38305 | NULL | donec1f9075b020fe8e4a5e7ebae74c38e76 | 1 | 2025-04-14 | 2025-04-20 | 2 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38306 | 424 | donec1f9075b020fe8e4a5e7ebae74c38e76 | 1 | 2025-04-01 | 2025-04-30 | 3 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38307 | 8266 | donec1f9075b020fe8e4a5e7ebae74c38e76 | 1 | 2025-01-01 | 2025-12-31 | 4 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38308 | NULL | done5d6556a3a658d05f4bf2bd19fa1e7daf | 1 | 2025-04-15 | 2025-04-15 | 1 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38309 | NULL | done5d6556a3a658d05f4bf2bd19fa1e7daf | 1 | 2025-04-14 | 2025-04-20 | 2 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38310 | 425 | done5d6556a3a658d05f4bf2bd19fa1e7daf | 1 | 2025-04-01 | 2025-04-30 | 3 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
| 38311 | 8265 | done5d6556a3a658d05f4bf2bd19fa1e7daf | 1 | 2025-01-01 | 2025-12-31 | 4 | 2025-05-14 19:15:05 | NULL | 0 | NULL | NULL | NULL |
+----------------+-----------+--------------------------------------+--------+------------+------------+--------+---------------------+------------+--------+--------+-----------------+------------+
12 rows in set (0.00 sec)







0 Comments

Examples of console core:archive in Matomo

2/16/2024

0 Comments

 
  1. Note: don't run as root! I learned
  2. sudo  php /var/www/littlefurnace.com/matomo/console  core:archive --force-idsites=1

    (On Windows? The syntax in Windows terminals is more like this:
    C:\PHP\php.exe           "C:\examplebank\wwwroot\matomo\console" core:archive    --force-idsites=1
    ​

  3. This will take a long time. You are forcing Site 1 to reprocess everything, since the beginning of time. It will run for at least a few minutes. But it might go on and on for hours.
  4. sudo  php /var/www/littlefurnace.com/matomo/console  core:archive --force-idsites=1 --force-date-range=2024-02-01,today

    This will only take a few minutes usually.
  5. Try running any core:archive command twice in a row.
    Result: the second time you run it, there are usually zero lines processed.
  6. Try running any core:archive then core:invalidate-report-data, and run the original core:archive
    Result: depending on which data you invalidate, you can make the core:archive process a non-zero number of lines
0 Comments

Does Matomo use cookies? Yes!

2/2/2024

1 Comment

 
Picture
If you are a hater of cookies, Matomo is able to run with no cookies. There is a setting in the user interface: cookies are easy to disable.*

But cookies are enabled by default. Why? The Matomo Visitor ID cookie is a first party cookie! Look it up: that's a respectful, ethical type of cookie.  And the data it collects goes to your website, only.  So if you are trying to keep a lot of secrets about what goes on in your website, Matomo is the way to do it. 

Matomo explicitly promises that they have no interest in your data. See these:
https://matomo.org/100-data-ownership/
https://matomo.org/matomo-cloud-privacy-policy/ (Matomo Cloud only)

How to see the Visitor ID, and confirm that Matomo sets a cookie during the visit:
  1. Go to your website in a browser.
  2. Open devtools >> Application/Storage/Cookies
  3. pk_id is the visitor ID. Its value is a 16 char string.
  4. Go to your Matomo dashboard.
  5. You can see this 16 char string in Visitors >> Visits Log (see the screenshot above)

*What Matomo loses when you disable the Matomo cookie, is it cannot detect a returning visitor. This messes up some of the more subtle things you would want to know about your website. Returning visitors are a pretty big deal to understand.

1 Comment

Experiment: In the browser console, manually set the User ID

11/10/2023

0 Comments

 

Here is something you can try in the console of any browser if you are visiting a page which uses the Matomo Tracker JS.

  1. Open:
    Browser >> Dev Tools >> Console
  2. Enter these 4 commands one at a time in this order, hitting <ENTER> after each one
  3. _paq.push(["setUserId", anExampleVariable]); <ENTER>
  4. let anExampleVariable = "The Man in the Moon"; <ENTER>
  5. _paq.push(["setUserId", anExampleVariable]); <ENTER>
  6. _paq.push([ function() {console.log(this.getUserId());}]); <ENTER>

Step 6 allows you to test whether Matomo stored the name of the User ID.

Then let's do this using your website where you have stored the name of your website visitor. We are going to take the visitor's name and store it as their Matomo UserID.

Let's assume your website allows the user to sign in, with a password, and the username is stored in a JS variable in the browser called
first_and_last.

In a browser which has your user's web page load your website. Sign in as a username in your website:
  1. Browser >> Dev Tools >> Console
  2. Enter these 3 commands one at a time in this order, hitting <ENTER> after each one
  3. first_and_last; <ENTER> just to see if your name is already in the page, nothing to do with Matomo yet
  4. _paq.push(["setUserId", first_and_last]); <ENTER>
  5. _paq.push([ function() {console.log(this.getUserId());}]); <ENTER>

Setting the UserID in Matomo has benefits:
  • You can see the UserID immediately in Dashboard >> Visits >> Visits Log
  • You can see a special report on signed in users at Dashboard >> Visitors >> User IDs
  • You can detect each history of each visitor on your site, including the monetary value of their conversions.  (You have to set up the conversions manually - see links below. Once you set these up, you can start measuring the rich data of how often and how much are the conversions worth, over time, for this visitor.)

Matomo uses three ways to string together repeated visits over time for a visitor. The weakest but most legal (most private) is the scrambled fingerprint number. This is remembered only for today (actually less than today: for privacy, this ID is deleted within 30 minutes of the session end.) You can make this time longer than 30 minutes but it puts a high demand on your CPU if you try to set it for several days duration. Still, this might work for a low traffic website.   It will not work for Matomo for Wordpress: those deployments have small resources in the hardware: Matomo has to share CPU and SQL database with the WP resources. Not good.

Stronger than this is detection by first-party cookies.  By default, Matomo will do this. If you want to be super private with your visitors data you should disable this.

Strongest of all is detection by User ID. UserID is what we experimented with at the top of this article.

Read more at the official Matomo Docs:
How does Piwik detect unique and returning visitors? (with User ID or Visitor ID from tracking cookie)
https://matomo.org/guide/reports/user-ids/
https://matomo.org/guide/reports/goals-and-conversions/



0 Comments
<<Previous

    Author

    Evan Genest

    Archives

    November 2024
    August 2024
    May 2024
    March 2024
    February 2024
    November 2023
    October 2023
    September 2023
    August 2023

    Categories

    All

Powered by Create your own unique website with customizable templates.
  • Home
  • What is Matomo
  • Contact
  • Custom Reports
  • Connect Matomo to other software
  • CLI API etc
  • Matomo Tag Manager Simple Guide
  • Lyn Only
  • Troubleshooting + Deploying Matomo
  • Weird Data
  • Why is data in Matomo giving different numbers than Google Analytics
  • The Dashboard
  • Moving the Data
  • Book Club Forum