Matomo Drupal

This FAQ details the few different use cases and configurations when using a proxy in Matomo (Piwik). If Matomo is behind a reverse proxy. If you install Matomo, connecting through a reverse proxy (https-to-http), the following line should be automatically added to your config/config.ini.php file during the Matomo installation. Matomo Analytics module makes it easy to add Matomo tracking code into your Drupal website and start tracking your visitors behaviour instantly. Even the users who don’t have any technical experience will be able to achieve this with ease. You’ll need Matomo (Cloud or Self-hosted) and Drupal.

  1. Matomo Drupal 6
  2. Matomo Drupal Download
  3. Matomo Wordpress
  4. Matomo Drupal Google
Drupal
Feedback sent successfully Thank you for your valuable feedback. We will use it to make matomo.org even better.

This FAQ details the few different use cases and configurations when using a proxy in Matomo (Piwik).

If Matomo is behind a reverse proxy

If you install Matomo, connecting through a reverse proxy (https-to-http), the following line should be automatically added to your config/config.ini.php file during the Matomo installation:

If you install Matomo from behind the reverse proxy (where Matomo can’t detect https will be used), you should set the above manually. Also, depending on your proxy server, the Visitor IP is set in a different HTTP Header which should also be automatically detected on install and added to your config/config.ini.php:

Matomo drupal 7

If Matomo was unable to detect your proxy configuration, you may add these lines manually in your Matomo config.ini.php file (remove the leading “;” character to enable the setting).

Be aware that PHP applies some transforms to headers: uppercases them, prefixes HTTP_ and converts dashes to underscores. So if your reverse proxy is sending X-Forwarded-For, it should be entered in the config as HTTP_X_FORWARDED_FOR.

It is also possible to check multiple proxy_client_headers, which will be checked in order until a header value is found. For example, with the config below:

This means first try the HTTP_WAF_FORWARDED_FOR header and if that doesn’t exist, then try the HTTP_LB_FORWARDED_FOR and if neither exists then finally try HTTP_X_FORWARDED_FOR. The array[] syntax is shorthand in PHP for array_push so adds to the existing array.

You can exclude internal IPs (e.g. LoadBalancer IPs) from being used from these headers using the proxy_ips[] config to exclude certain ranges of IP addresses. For example the following config will ignore commonly used internal IP address ranges:

It is also possible to debug this to list the exact details in the Matomo log file.

Notes:

  • If your server runs IIS reverse proxy, HTTP_X_FORWARDED_HOST needs to be added manually to “Allowed Server Variables” and added to the inbound rewrite rule and set to {HTTP_HOST} so that it passes through the original HTTP_HOST value provided by the client to Matomo. Learn more.

  • If you use Apache 2.4 or Apache 2.5, there is an alternative solution, you could use mod_remoteip to override the client IP with the IP as provided by a proxy or load balancer. Then you won’t need to specify these Matomo config settings.

If Matomo is behind a reverse proxy and installed in a sub-path

If you’re using Matomo behind a reverse proxy with a different path such as rewrite ^/piwik/(.*)$ /$1 break; (in nginx.conf when Matomo is installed in the /piwik path), you would need to:

1) configure your web server to provide a header HTTP_X_FORWARDED_URI. For example on NGINX, when Matomo is installed in /piwik path, you would set proxy_set_header X-Forwarded-Uri /piwik; in your nginx.conf.
2) configure Matomo to read this HTTP_X_FORWARDED_URI to construct correct URLs. In Matomo config/config.ini.php in the [General] section add:

Matomo is behind an outgoing proxy

If your server is configured behind an outgoing proxy, check out this FAQ: outgoing Proxy easy setup in Matomo.

Matomo Drupal 6

You might also be interested in…

Matomo
  • How do I force Matomo login to use SSL (https)?.
Thanks for contacting us! We will get in touch with you shortly.

Matomo Drupal Download

Feedback on this page

Feedback sent successfully Thank you for your valuable feedback. We will use it to make matomo.org even better.

At times it can be hard to integrate Analytics tools into your CMS like Drupal. Matomo Analytics module makes it easy to add Matomo tracking code into your Drupal website and start tracking your visitors behaviour instantly. Even the users who don’t have any technical experience will be able to achieve this with ease.

Google

You’ll need Matomo (Cloud or Self-hosted) and Drupal.

Note: This guide is written in an assumption that you have already installed Matomo Analytics for Drupal module in your website

Integrate Matomo Analytics to your Drupal site

To configure the plugin, follow the steps below:

  1. Open Drupal Administration page

  2. Click on “Extend” on the top menu bar

  3. Click on “Install new module” and choose the downloaded module and click on “Install”.

  4. Search for Matomo in the search bar, you will be able to see the module if it is installed properly

  5. Click on the small arrow on the right side of the name Matomo Analytics

  6. Click on “Configure”

  7. Enter the siteId in the “Matomo Site ID” field. How to get site ID?

  8. Enter your Matomo instance URL (ex: https://example.matomo.cloud/) in “Matomo HTTPS URL”, make sure ‘/’ is added at the end

  9. If you would like to add some Custom JavaScript code to your Matomo Tracking code, you can do so under “Advanced Settings > Custom Snippet”

  10. Scroll down to the bottom at Click on “Save Configuration”

  11. Open your website in the browser and perform some actions (eg: navigate to different pages)

  12. Login to your Matomo instance to check if you’re getting the tracking data of your site

Congratulations, you should now be successfully tracking visitors with Matomo Analytics through your Drupal site! Happy Analytics.

Thanks for contacting us! We will get in touch with you shortly.

Matomo Wordpress

Feedback on this page

Matomo Drupal Google