If you like my work, please consider supporting its development.

Midnight comes with support for Matomo as an site analytics provider. This requires having a Matomo instance hosted somewhere, either self-hosted or hosted by Innocraft. The theme uses the JavaScript tracking client.


Set enable to true and host to the root URL of the Matomo installation under params.matomo in your site's configuration file. If your Matomo installation tracks multiple websites, add the site ID number in site_id.

    enable = true
    # URL to the root of the matomo installation.
    # Can include paths after the TLD (e.g https://example.com/matomo/)
    host = "https://matomo.example.com"
    # ID number of this site. Defaults to 1 if not included
    site_id = 2
    # Include <noscript> tags to track users with javascript disabled
    track_nojs = true
    # Include a link in the site footer to allow users to opt out of analytics
    enable_optout = true
        enable: true
        host: https://matomo.example.com
        site_id: 2
        track_nojs: true
        enable_optout: true
    "params": {
        "matomo": {
            "enable": true,
            "host": "https://matomo.example.com",
            "site_id": 2,
            "track_nojs": true,
            "enable_optout": true

All configurations options:

Option NameDescription
enableEnable Matomo analytics on your website.

The root domain/path of your Matomo instance. Examples: https://matomo.example.com or https://example.com/matomo.


The ID number of this site in your Matomo instance. Typically the first one set up is 1, the second is 2, etc. Defaults to 1 if not specified.


Track users who are not using JavaScript by adding an invisible image to the page. Defaults to false.


Add an optout link to the footer of the site for users to be able to opt out of being tracked. Currently requires setting up Ajax one-click optout (below).

Ajax “one-click” opt-out

Matomo currently only provides an <iframe> as a method of opting out of being tracked. It sucks, looks bad on a themed page, and just generally isn't a great idea. A user thought so too and created a plugin that allows developers to create an opt-out button. *GASP!*

I recommend you install the above plugin and enable support for one-click opting out with the below configuration:

Matomo Configuration

You will need to enable cross-domain requests in your Matomo installation and set the Access-Control-Allow-Credentials header to true on the server hosting Matomo.

Add the following line inside the server{} block for Matomo (not your Hugo site):

Add the following to your server's <VirtualHost> block or to a .htaccess file at the root of your Matomo installation.