How do I go cookieless (disable all cookies) for a visitor?
In some countries, the law requests websites to provide a way for users to opt-out of all tracking, in particular tracking cookies. Matomo uses cookies to store some information about visitors between visits, however, it is possible to use Matomo Analytics without requiring cookies. This can be set up for all visits if you are willing to accept less specific data, or you might do it for all visits before they consent to further tracking. Whatever the reason, the method for disabling cookies is shown below and varies depending on which version of Matomo you are using.
Disable cookies for all sites within Matomo
If you never want to make use of cookies in any of your sites, then you can simply disable cookies for all sites.
Disable cookies for a specific site when you are using Matomo On-Premise or Matomo Cloud
See also: List of cookies used by Matomo.
If you have installed Matomo on your website with the JavaScript tracking code, it is easy to disable tracking cookies by adding one line in the Matomo Javascript code. Simply find the tracking code in your sites editor and look for the line that includes _paq.push(['trackPageView']);
and add the function _paq.push(['disableCookies']);
on the line before that. So afterwards that section of your code will look a little something like this:
[...]
// Call disableCookies before calling trackPageView
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
[...]
That’s it! Matomo will no longer collect any personal data through tracking cookies. If you’d only like to disable cookies until someone has consented to their use, view the developer documentation on cookie consent.
If you are using Matomo for WordPress
Log in to your WordPress Admin Dashboard. Go to “Matomo Analytics -> Settings”. You will see the tracking settings page. To disable cookies enable the option “Disable cookies” and press “Save changes”.
- Log in to your WordPress Admin Dashboard.
- Go to the Matomo Analytics section and click to view the Settings page.
- Scroll down to the Disable cookies checkbox and make sure it is selected.
- Scroll to the bottom of the page and click Save changes to confirm.
If you are using Matomo Tag Manager
There are two main ways of disabling cookies via Tag Manager, depending on whether you are using a cookie consent solution or not.
Cookies fully disabled
You can use a built-in feature that enables you to disable cookies. When setting up your Matomo configuration variable, make sure the Disable Cookies checkbox is enabled.
- When creating a Matomo Tag, you will see a Matomo Configuration setting. If you haven’t already created one, then click the Create New Matomo Configuration link to load the builder.
- Once it has loaded, complete all of the required details and then scroll down to the checkbox that says Disable cookies.
- Click Create New Variable to confirm your configuration.
When using Matomo Tag Manager with a cookie consent solution
If you still want to use cookies if user gives consent, then you can create a “Custom HTML” tag, and insert _paq.push(['requireCookieConsent']);
in this tag. You would also need to create a Trigger on “DOM Ready” (which will be executed first before the Pageview trigger). Then in your Custom HTML tag, set “Execute this tag when any of these triggers are triggered.” to “DOM Ready”.
Implications on data accuracy
Learn more how cookie affect data accuracy in our FAQ: When cookies are disabled by a visitor, how does it impact Matomo (Piwik) reports accuracy?
Implication on cookie consent banner and asking user for consent
You can avoid the analytics cookie consent banner by disabling all analytics cookies in your JavaScript tracking code (as per instructions above). Learn more about tracking analytics without consent or cookie banner
Essential non-analytics cookies that may still be created
It is important to note that even when cookies are disabled, Matomo may still set essential cookies in some cases, but these are purely functional and contain no personal data that would be covered by privacy laws. In fact, all of these cookies are actually designed to increase user security and privacy. The essential cookies and the reasons you might expect to find them are:
- piwik_ignore – When you exclude yourself from being tracked using the cookie method or using the iframe opt-out method, Matomo will create a cookie
piwik_ignore
set on the domain of your Matomo server - MATOMO_SESSID –
MATOMO_SESSID
is a temporary short-lived cookie that provides a nonce – basically a random number – which helps to prevent CSRF security issues while users opt-out of tracking. - mtm_consent and mtm_consent_removed – When you’re asking for consent before tracking visitors, these two cookies may be created:
mtm_consent
andmtm_consent_removed
. - _pk_testcookie – The
_pk_testcookie
is only used to check whether the visitor’s browser supports cookies and is created without any identifier and is directly deleted.