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)

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



Leave a Reply.

    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