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)

An index of every ./console command in Matomo

9/19/2023

1 Comment

 
Picture
Console is a tool from the Symfony PHP platform. Matomo is built with Symfony. A good introduction to Console syntax in Matomo may be to just read a list of all of its commands.

Have you ever wanted to reach into the PHP of Matomo and run a certain part of it, manually, without using clicking on any part of the GUI dashboard? Console gives us a well organized syntax for running sub-modules of Matomo's PHP inside of our Matomo server, by typing them as commands in the terminal.

This is a list of the commands I find most relevant to my Matomo deployment.

EVERY  _______:_______ COMMAND
(you may be missing some, if you don't have certain plugins installed)

$ sudo php ./console --list
 
campusgeoip
  campusgeoip:geolocate                              Geo Locate IP Addresses (comma seperated)
  campusgeoip:resolve-network-ranges                 Resolve the network_start and network_end values for networks with cidr and NULL ranges. Useful if the networks table is populated by external means (Sequel Ace, phpMyAdmin, mysql client)
  campusgeoip:test-against-visit-log                 Harvests IPs from visitor log and tests them against resolver database.
  campusgeoip:update-networks                        UpdateNetworks
 
climulti

  climulti:request                                   Parses and executes the given query. See Piwik\CliMulti. Intended only for system usage.
 config
  config:delete                                      Delete a config setting
  config:get                                         Get a config value or section
  config:set                                         Set one or more config settings in the file config/config.ini.php

core
  core:archive                                       Runs the CLI archiver. It is an important tool for general maintenance and to keep Piwik very fast.
  core:calculate-conversion-pages                    Calculate the pages before metric for historic conversions
  core:clear-caches                                  [cache:clear] Clears all caches. This command can be useful for instance after updating Matomo files manually.
  core:create-security-files                         Creates some web server security files if they haven't existed previously. Useful when using for example Apache or IIS web server and Matomo cannot create these files automatically because of missing write permissions.
  core:delete-logs-data                              Delete data from the user log tables: log_visit, log_link_visit_action, log_conversion, log_conversion_item, log_action.
  core:fix-duplicate-log-actions                     Removes duplicates in the log action table and fixes references to the duplicates in related tables. NOTE: This action can take a long time to run!
  core:invalidate-report-data                        Invalidate archived report data by date range, site and period.
  core:matomo4-migrate-token-auths                   Only needed for the matomo 3 to matomo 4 migration
  core:purge-old-archive-data                        Purges out of date and invalid archive data from archive tables.
  core:test-email                                    Send a test email
  core:update                                        Triggers upgrades. Use it after Matomo core or any plugin files have been updated. Append --yes to upgrade without confirmation.
  core:version                                       Returns the current version information of this Matomo instance.

custom-piwik-js

  custom-piwik-js:update                             [custom-matomo-js:update] Update the Javascript Tracker with plugin tracker additions
 customdimensions
  customdimensions:add-custom-dimension              Add new Custom Dimension available.
  customdimensions:info                              Get information about currently installed Custom Dimensions
  customdimensions:remove-custom-dimension           Removes an existing Custom Dimension
 customreports
  customreports:archive                              Let's you trigger custom reports archiving for given site and date range
  customreports:generate-reports                     GenerateReports

database

  database:optimize-archive-tables                   Runs an OPTIMIZE TABLE query on the specified archive tables.

development

  development:build-tracker-js                       Minifies tracker JavaScript for Matomo core or a single plugin.
  development:enable                                 [development:disable] Enable or disable development mode. See config/global.ini.php in section [Development] for more information
  development:get-segment-sql                        Print out the SQL used to query for a segment. Used for debugging or diagnosing segment issues. The site ID and dates are hardcoded in the query.
  development:sync-system-test-processed             For Piwik core devs. Copies processed system tests from travis artifacts to local processed directories
  development:test-files                             Manage test files.

diagnostics

  diagnostics:analyze-archive-table                  Analyze an archive table and display human readable information about what is stored. This command can be used to diagnose issues like bloated archive tables.
  diagnostics:archiving-config                       Show configuration settings that can affect archiving performance
  diagnostics:archiving-instance-statistics          Show data statistics which can affect archiving performance
  diagnostics:archiving-metrics                      Show metrics describing the current archiving status
  diagnostics:archiving-queue                        Show the current state of the archive invalidations queue as a table
  diagnostics:archiving-status                       
  diagnostics:run                                    Run diagnostics to check that Piwik is installed and runs correctly
  diagnostics:unexpected-files                       Show a list of unexpected files found in the Matomo installation directory and optionally delete them.


generate

  generate:api                                       Adds an API to an existing plugin
  generate:archiver                                  Adds an Archiver to an existing plugin
  generate:command                                   Adds a command to an existing plugin
  generate:controller                                Adds a Controller to an existing plugin
  generate:dimension                                 Adds a new dimension to an existing plugin. This allows you to persist new values during tracking.
  generate:menu                                      Adds a plugin menu class to an existing plugin
  generate:plugin                                    [generate:theme] Generates a new plugin/theme including all needed files
  generate:report                                    Adds a new report to an existing plugin
  generate:scheduledtask                             Adds a tasks class to an existing plugin which allows you to specify scheduled

tasks
  generate:settings                                  Adds a SystemSetting, UserSetting or MeasurableSetting class to an existing plugin
  generate:system-check                              Adds a new system check to an existing plugin
  generate:tagmanager-datalayer-variable             Generate a preconfigured data layer variable
  generate:tagmanager-preconfigured-variable         Generate Preconfigured Variable
  generate:tagmanager-tag                            Generate Tag
  generate:tagmanager-trigger                        Generate Trigger
  generate:tagmanager-variable                       Generate Variable
  generate:test                                      Adds a test to an existing plugin
  generate:update                                    Adds a new update to an existing plugin or "core"
  generate:visualizationplugin                       Generates a new visualization plugin including all needed files
  generate:vue-component                             Generates a vue component for a plugin.
  generate:widget                                    Adds a plugin widget class to an existing plugin

heatmapsessionrecording
  heatmapsessionrecording:remove-heatmap-screenshot  Removes a saved heatmap screenshot which can be useful if you want Matomo to re-take this screenshot. If the heatmap is currently ended, it will automatically restart it.

log

  log:watch                                          Outputs the last parts of the log files and follows as the log file grows. Does not work on Windows

login

  login:unblock-blocked-ips                          Unblocks all currently blocked IPs. Useful if you cannot log in to your Matomo anymore because your own IP is blocked

marketplace

  marketplace:set-license-key                        Sets a marketplace license key

plugin

  plugin:activate                                    Activate a plugin.
  plugin:deactivate                                  Deactivate a plugin.
  plugin:list                                        List installed plugins.
  plugin:uninstall                                   Uninstall a plugin.

privacymanager

  privacymanager:anonymize-some-raw-data             Anonymize some of the stored raw data (logs). The reason it only anonymizes "some" data is that personal data can be present in many various data collection points, for example some of your page URLs or page titles may include personal data and these will not be anonymized by this command as it is not possible to detect personal data for example in a URL automatically.

queuedtracking

  queuedtracking:lock-status                         Outputs information for the status of each locked queue. Unlocking a queue is possible as well.
  queuedtracking:monitor                             Shows and updates the current state of the queue every 2 seconds.
  queuedtracking:print-queued-requests               Prints the requests of each queue that will be processed next.
  queuedtracking:process                             Processes all queued tracking requests in case there are enough requests in the queue and in case they are not already in process by another script. To keep track of the queue use the --verbose option or execute the queuedtracking:monitor command.
  queuedtracking:test                                Test your Redis connection get some information about your current system.
 scheduled-tasks
  scheduled-tasks:run                                [core:run-scheduled-tasks] Will run all scheduled tasks due to run at this time.

tagmanager

  tagmanager:regenerate-released-containers          Re-generates all released container files
 trackingspamprevention
  trackingspamprevention:block-geo-ip-organisation   Blocks a new GeoIP organisation. It will save the organisation in the config file.

translations

  translations:fetch                                 Fetches translations files from Weblate to /var/www/littlefurnace.com/matomo/tmp/weblate
  translations:generate-intl-data                    Generates Intl-data for Piwik
  translations:languagecodes                         Shows available language codes
  translations:languageinfo                          Shows available languages info
  translations:languagenames                         Shows available language names
  translations:plugins                               Shows all plugins that have own translation files
  translations:set                                   Sets new translations for a given language
  translations:update                                Updates translation files
  translations:validate                              Validates translation files

twofactorauth

  twofactorauth:disable-2fa-for-user                 Disable two-factor authentication for a user. Useful if a user loses the device that was used for two-factor authentication. After it was disabled, the user will be able to set it up again.

usercountry

  usercountry:attribute                              Re-attribute existing raw data (visits & conversions) with geolocated location data, using the specified or configured location provider.
  usercountry:convert-region-codes                   Convert FIPS region codes saved by GeoIP legacy provider to ISO.
  usercountry:update-region-codes                    Updates the ISO region names

visitorgenerator

  visitorgenerator:anonymize-log                     Anonymizes an Apache log file by anonymizing IPs and domains. It will not replace any search terms, paths or url queries. The original file will not be altered.
  visitorgenerator:generate-annotation               Generates an annotation for the current day. This command is intended for developers.
  visitorgenerator:generate-goals                    Generates a few predefined goals for a specific site. If one of the predefined goals already exist they will not be created again. This command is intended for developers.
  visitorgenerator:generate-live-visits              Continuously generates visits from a single log file to make it seem like there is real time traffic.
  visitorgenerator:generate-users                    Generates many users. This command is intended for developers.
  visitorgenerator:generate-visits                   Generates many visits for a given amount of days in the past. This command is intended for developers.
  visitorgenerator:generate-visits-db                Generates many visits for a given amount of days in the past, directly inserted into the database. This command is intended for developers.
  visitorgenerator:generate-websites                 Generates many websites. This command is intended for developers.
  visitorgenerator:shorten-log                       Shortens an Apache log file by keeping only a small number of logs per day.

vue

  vue:build                                          Builds vue modules for one or more plugins.
  vue:build-polyfill                                 Builds the polyfill UMD.
evan@nodejs-nyc:~$ 

THE SUBCATEGORIES OF CORE

TWELVE CORE COMMANDS

core:matomo4-migrate-token-auths
core:fix-duplicate-log-actions
core:invalidate-report-data
core:purge-old-archive-data
core:create-security-files
core:run-scheduled-tasks
core:delete-logs-data
core:clear-caches
core:test-email
core:version
core:archive
core:update [Query: , CLI mode: 1]

THE OPTIONS OF CORE:INVALIDATE

$ sudo php ./console core:invalidate --help


Options:
 --dates                      List of dates or date ranges to invalidate report data for, eg, 2015-01-03 or 2015-01-05,2015-02-12. (multiple values allowed)
 --sites                      List of site IDs to invalidate report data for, eg, "1,2,3,4" or "all" for all sites. (default: "all")
 --periods                    List of period types to invalidate report data for. Can be one or more of the following values: day, week, month, year or "all" for all of them. (default: "all")
 --segment                    List of segments to invalidate report data for. This can be the segment string itself, the segment name from the UI or the ID of the segment. If specifying the segment definition, make sure it is encoded properly (it should be the same as the segment parameter in the URL. (multiple values allowed)
 --cascade                    If supplied, invalidation will cascade, invalidating child period types even if they aren't specified in --periods. For example, if --periods=week, --cascade will cause the days within those weeks to be invalidated as well. If --periods=month, then weeks and days will be invalidated. Note: if a period falls partly outside of a date range, then --cascade will also invalidate data for child periods outside the date range. For example, if --dates=2015-09-14,2015-09-15 & --periods=week, --cascade will also invalidate all days within 2015-09-13,2015-09-19, even those outside the date range.
 --dry-run                    For tests. Runs the command w/o actually invalidating anything.
 --plugin                     To invalidate data for a specific plugin only.
 --ignore-log-deletion-limit  Ignore the log purging limit when invalidating archives. If a date is older than the log purging threshold (which means there should be no log data for it), we normally skip invalidating it in order to prevent losing any report data. In some cases, however it is useful, if, for example, your site was imported from Google, and there is never any log data.
 --help (-h)                  Display this help message
 --quiet (-q)                 Do not output any message
 --verbose (-v|vv|vvv)        Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)               Display this application version
 --ansi                       Force ANSI output
 --no-ansi                    Disable ANSI output
 --no-interaction (-n)        Do not ask any interactive question
 --matomo-domain              Matomo URL (protocol and domain) eg. "http://matomo.example.org"
 --xhprof                     Enable profiling with XHProf
 --ignore-warn                Return 0 exit code even if there are warning logs or error logs detected in the command output.

 

THE OPTIONS OF CORE:ARCHIVE

$ sudo php ./console core:archive --help

Options:
--url Forces the value of this option to be used as the URL to Piwik.
If your system does not support archiving with CLI processes, you may need to set this in order for the archiving HTTP requests to use the desired URLs.
--skip-idsites If specified, archiving will be skipped for these websites (in case these website ids would have been archived).
--skip-all-segments If specified, all segments will be skipped during archiving.
--force-idsites If specified, archiving will be processed only for these Sites Ids (comma separated)
--skip-segments-today If specified, segments will be only archived for yesterday, but not today. If the segment was created or changed recently, then it will still be archived for today and the setting will be ignored for this segment.
--force-periods If specified, archiving will be processed only for these Periods (comma separated eg. day,week,month,year,range)
--force-date-last-n Deprecated. Please use the "process_new_segments_from" INI configuration option instead.
--force-date-range If specified, archiving will be processed only for periods included in this date range. Format: YYYY-MM-DD,YYYY-MM-DD
--force-idsegments If specified, only these segments will be processed (if the segment should be applied to a site in the first place).
Specify stored segment IDs, not the segments themselves, eg, 1,2,3.
Note: if identical segments exist w/ different IDs, they will both be skipped, even if you only supply one ID.
--concurrent-requests-per-website When processing a website and its segments, number of requests to process in parallel (default: 3)
--concurrent-archivers The number of max archivers to run in parallel. Depending on how you start the archiver as a cronjob, you may need to double the amount of archivers allowed if the same process appears twice in the `ps ex` output. (default: false)
--max-websites-to-process Maximum number of websites to process during a single execution of the archiver. Can be used to limit the process lifetime e.g. to avoid increasing memory usage.
--max-archives-to-process Maximum number of archives to process during a single execution of the archiver. Can be used to limit the process lifetime e.g. to avoid increasing memory usage.
--disable-scheduled-tasks Skips executing Scheduled tasks (sending scheduled reports, db optimization, etc.).
--accept-invalid-ssl-certificate It is _NOT_ recommended to use this argument. Instead, you should use a valid SSL certificate!
It can be useful if you specified --url=https://... or if you are using Piwik with force_ssl=1
--php-cli-options Forwards the PHP configuration options to the PHP CLI command. For example "-d memory_limit=8G". Note: These options are only applied if the archiver actually uses CLI and not HTTP. (default: "")
--force-all-websites Force archiving all websites.
--force-report If specified, only processes invalidations for a specific report in a specific plugin. Value must be in the format of "MyPlugin.myReport".
--help (-h) Display this help message
--quiet (-q) Do not output any message
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
--no-interaction (-n) Do not ask any interactive question
--matomo-domain Matomo URL (protocol and domain) eg. "http://matomo.example.org"
--xhprof Enable profiling with XHProf
--ignore-warn Return 0 exit code even if there are warning logs or error logs detected in the command output.
Help:
* It is recommended to run the script without any option.
* This script should be executed every hour via crontab, or as a daemon.
* You can also run it via http:// by specifying the Super User &token_auth=XYZ as a parameter ('Web Cron'),
but it is recommended to run it via command line/CLI instead.
* If you have any suggestion about this script, please let the team know at [email protected]
* Enjoy!

The options of core:delete-logs-data

core:delete-logs-data 
Description:
  Delete data from the user log tables: log_visit, log_link_visit_action, log_conversion, log_conversion_item, log_action.

Usage:
  core:delete-logs-data [options]

Options:
      --dates=DATES                    Delete log data with a date within this date range. Eg, 2012-01-01,2013-01-01
      --idsite[=IDSITE]                Delete log data belonging to the site with this ID. Comma separated list of website id. Eg, 1, 2, 3, etc. By default log data from all sites is purged.
      --limit=LIMIT                    The number of rows to delete at a time. The larger the number, the more time is spent deleting logs, and the less progress will be printed to the screen. [default: 1000]
      --optimize-tables                If supplied, the command will optimize log tables after deleting logs. Note: this can take a very long time.
  -h, --help                           Display help for the given command. When no command is given display help for the list command
  -q, --quiet                          Do not output any message
  -V, --version                        Display this application version
      --ansi|--no-ansi                 Force (or disable --no-ansi) ANSI output
  -n, --no-interaction                 Do not ask any interactive question
      --matomo-domain[=MATOMO-DOMAIN]  Matomo URL (protocol and domain) eg. "http://matomo.example.org"
      --xhprof                         Enable profiling with XHProf
      --ignore-warn                    Return 0 exit code even if there are warning logs or error logs detected in the command output.
  -v|vv|vvv, --verbose                 Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Plugins

When you add new modules (plugins), Matomo will add new Console commands.  

For example, users of the Queued Tracking module will have this command available:
 queuedtracking:monitor

See a list of  free and paid Matomo plugins here: 
​https://plugins.matomo.org/

More

Want to see the PHP code that Console is spinning up behind each command? The entire core code of Matomo is opensource.

You can browse every line of Matomo code here:
https://github.com/matomo-org/matomo

You can download an older version of Matomo (like Version 3, Version 4) here:
https://builds.matomo.org/
​
1 Comment
Dag Nasty
2/16/2024 04:23:54 pm

Then someone is coming over in a few days later and I can come back in the morning if that works for you.

Reply



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