# Matomo Analytics

**URL:** https://meta.discourse.org/t/matomo-analytics/33090
**Category:** Theme component
**Tags:** official, matomo-analytics
**Created:** [September 10, 2015, 10:18am UTC](https://meta.discourse.org/t/matomo-analytics/33090 "2015-09-10T10:18:13Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [September 10, 2015, 10:18am UTC](https://meta.discourse.org/t/matomo-analytics/33090/1 "2015-09-10T10:18:13Z")

</div>

| | | |
| --- | --- | --- |
| :discourse2: | **Summary** | **Matomo Analytics** is a script to enable Matomo analytics on Discourse. |
| :hammer_and_wrench: | **Repository Link** | [https://github.com/discourse/discourse-matomo-analytics](https://github.com/discourse/discourse-matomo-analytics) |
| :open_book: | **New to Discourse Themes?** | [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) |

Install this theme component

> [@](#):
>
> :discourse2: As this is an #official theme component maintained by the Discourse team, #Support, #Contribute > Bug, #Contribute > UX, and #Contribute > Feature requests can be made in the respective categories here on Meta, and tagged with the appropriate theme component tag. Click on a link below to get one started. :+1:
> 
> [:question:&nbsp; **Support**](https://meta.discourse.org/new-topic?category_id=6&tags=matomo-analytics "Ask for support on configuring and using Matomo Analytics") [:bug:&nbsp; **Bug**](https://meta.discourse.org/new-topic?category_id=1&tags=matomo-analytics "A bug report means something is broken, preventing normal/typical use of the theme component") [:eyes:&nbsp; **UX**](https://meta.discourse.org/new-topic?category_id=9&tags=matomo-analytics "Discussion about the user interface of Matomo Analytics, and how features are presented (including language and UI elements)") [:bulb:&nbsp; **Feature**](https://meta.discourse.org/new-topic?category_id=2&tags=matomo-analytics "Discussion about how existing Matomo Analytics features can be improved or enhanced, and how proposed new features could work")

### Features

[Matomo](https://matomo.org/) is an open source analytics platform. Users can choose between self-hosting or paying for professional hosting in the cloud.

> :mega: Matomo was formerly named Piwik. See [Piwik is now Matomo - Announcement - Analytics Platform - Matomo](https://matomo.org/blog/2018/01/piwik-is-now-matomo/) for details about the name change.

To enable Matomo analytics on your Discourse forum, all you have to do is install the official theme component.

**Valid for Matomo API v1.5 and newer**

1. Follow the [theme installation guide](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682) to import from the following URL:

2. Enter the `Host URL` and `Website ID`

3. Add the theme component “Matomo Analytics” to your active theme(s).

That’s it!

### Settings

| Name | Description |
| --- | --- |
| host url | Host URL without http:// or https:// |
| website id | |
| exclude groups | Comma separated list of groups to exclude from tracking such as admins, staff |
| user id tracking | An indentifying field name on the current user object such as id, username or external\_id. |
| subdomain tracking | Track visitors across main domain & subdomains, assuming discourse is on a subdomain. |
| do not track | So tracking requests will not be sent if visitors do not wish to be tracked. |
| disable cookies | Disables all first party cookies. Existing Matomo cookies for this website will be deleted on the next pageview. |

### Credits

Thanks to @mattab & @brahn @tagtomat and @simon

  

> :discourse2: **Hosted by us?** Theme components are available to use on our Standard, Business, and Enterprise plans.

> Last edited by @david 2025-01-09T09:44:19Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![chrisblech](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@chrisblech](https://meta.discourse.org/u/chrisblech)
#### Post date: [October 31, 2016, 2:04pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/22 "2016-10-31T14:04:14Z")

</div>

Thanks for this howto, works fine for me. :thumbsup:

In order to comply with the European laws, users must have the possibility to reject piwik’s cookie. Piwik offers a really simple solution for this, by [including an IFrame](https://piwik.org/docs/privacy/#step-3-include-a-web-analytics-opt-out-feature-on-your-site-using-an-iframe).

Unfortunately, Discourse doesn’t allow iframe tags in posts… :grimacing:  
Does anyone see a way to include this piwik iframe in Discourse TOS ?  
Thanks.

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [October 23, 2018, 3:09pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/30 "2018-10-23T15:09:24Z")

</div>

:wave: I just created a new “Matomo Analytics” theme component, and updated [the instructions](https://meta.discourse.org/t/how-to-enable-matomo-analytics-on-discourse/33090) on how to set it up.

Could you give it a try? Please also remember to remove the original custom scripts.

---

<div class="post-metadata">

### Author: ![some-user](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@some-user](https://meta.discourse.org/u/some-user)
#### Post date: [October 23, 2018, 3:19pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/31 "2018-10-23T15:19:57Z")

</div>

Looks good on first sight. No error in javascript console. Requests to piwik.php being in the webserver log again.

Statistics in Matomo are available as well.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 23, 2018, 10:27pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/32 "2018-10-23T22:27:23Z")

</div>

Is this iframe thing still a concern?

---

<div class="post-metadata">

### Author: ![chrisblech](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@chrisblech](https://meta.discourse.org/u/chrisblech)
#### Post date: [October 24, 2018, 10:54pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/33 "2018-10-24T22:54:40Z")

</div>

Hey @xrav3nz :clap: your component works great - thanks!

> [@sam](#):
>
> Is this iframe thing still a concern?

Yes it is. Opt-out should be possible, and Matomo provides this via including an iFrame: [see Matomo documentation](https://matomo.org/docs/privacy/#step-3-include-a-web-analytics-opt-out-feature-on-your-site-using-an-iframe)

---

<div class="post-metadata">

### Author: ![Patrick\_David](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/patrick_david/32/119657_2.png) [@Patrick\_David](https://meta.discourse.org/u/Patrick_David)
#### Post date: [December 17, 2018, 8:30pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/34 "2018-12-17T20:30:10Z")

</div>

This doesn’t appear to be working for me at the moment? I can add the component, and add the correct URL and siteid, but it doesn’t render anything:

I added the comments around the code to find it quicker in the page:

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/9/9954b74cfdb3c6f0230e7e9f4c6a3db0764c1373.png)

---

<div class="post-metadata">

### Author: ![darix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/darix/32/114280_2.png) [@darix](https://meta.discourse.org/u/darix)
#### Post date: [December 17, 2018, 9:27pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/35 "2018-12-17T21:27:04Z")

</div>

We are on beta 6+git1 on our instance

---

<div class="post-metadata">

### Author: ![xrav3nz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/xrav3nz/32/76894_2.png) [@xrav3nz](https://meta.discourse.org/u/xrav3nz)
#### Post date: [December 18, 2018, 2:37pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/36 "2018-12-18T14:37:41Z")

</div>

Inline JavaScripts in themes and components are automatically extracted to an external “theme JavaScript” file.

Could you try checking the one immediately after your comments?

 ![9954b74cfdb3c6f0230e7e9f4c6a3db0764c1373](https://global.discourse-cdn.com/meta/original/3X/e/b/eb233acdc9a421706791944343a2b8aba358558d.png)

---

<div class="post-metadata">

### Author: ![Patrick\_David](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/patrick_david/32/119657_2.png) [@Patrick\_David](https://meta.discourse.org/u/Patrick_David)
#### Post date: [December 18, 2018, 3:06pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/37 "2018-12-18T15:06:22Z")

</div>

~~This is at the main page on [https://discuss.pixls.us](https://discuss.pixls.us):~~

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/f/cfc57fa31540f3e737496c721d394edfe023cf95.png)

**Edit**  
Hold on, I’ve got a new hash on the file on recent refresh, it looks like the code is there. Thank you @xrav3nz!

Looks like it’s working now - not sure what I was doing wrong yesterday - user error.

---

<div class="post-metadata">

### Author: ![downey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/downey/32/166878_2.png) [@downey](https://meta.discourse.org/u/downey)
#### Post date: [April 19, 2019, 12:45am UTC](https://meta.discourse.org/t/matomo-analytics/33090/38 "2019-04-19T00:45:09Z")

</div>

So I have the JS loaded into the theme customizations, and the external “theme JavaScript file”`*` is linked in my test browser, just under where I inserted it like in the screenshot in a few posts earlier … BUT the requests aren’t coming through to the Matomo tracking web server.

(Tracking works fine for other non-Discourse sites, FWIW.)

Has anyone else seen that happen?

* * *

`* e.g. https://discourse-cdn.example.com/standard11/theme-javascripts/{numeric_string}.js?__ws=my-discourse-forum.example.org`

---

<div class="post-metadata">

### Author: ![surety](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/surety/32/156849_2.png) [@surety](https://meta.discourse.org/u/surety)
#### Post date: [September 19, 2019, 3:04am UTC](https://meta.discourse.org/t/matomo-analytics/33090/39 "2019-09-19T03:04:21Z")

</div>

Thanks for the component!

I’m confused why the tracking code is sending a custom variable called Anonymous. Isn’t that custom for your particular Matomo setup? It doesn’t seem like it should be there for everyone.

```plaintext
_paq.push(['setCustomVariable', 1, 'Anonymous', !currentUser, 'visit']);

```

I [added a few lines](https://github.com/ryan-boder/discourse-matomo-analytics/commit/25af850e96f361d834427da5ef28f3ec6cb002c7) so that it would track visitors between discourse on a subdomain and a main site. Happy to send a pull request if you want it.

---

<div class="post-metadata">

### Author: ![goaround](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/goaround/32/160650_2.png) [@goaround](https://meta.discourse.org/u/goaround)
#### Post date: [November 8, 2019, 8:14am UTC](https://meta.discourse.org/t/matomo-analytics/33090/40 "2019-11-08T08:14:02Z")

</div>

You have to whitelist your Matomo-URL inside the Content-Security-Policy-Header. Search for the admin setting content\_security\_policy\_script\_src and add your domain (with https:://) there

---

<div class="post-metadata">

### Author: ![danb35](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@danb35](https://meta.discourse.org/u/danb35)
#### Post date: [November 9, 2019, 12:33am UTC](https://meta.discourse.org/t/matomo-analytics/33090/41 "2019-11-09T00:33:50Z")

</div>

I’m having trouble making this work on my installation. I’ve installed the component, and added it to my theme, but Matomo is saying there’s no data for the site. I’d think I have the settings correct:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/e/bebb7ad2144f7e5d4a0b3d6d6defd32ab386c64d.png)  
 ![image](https://global.discourse-cdn.com/meta/original/3X/e/9/e9bb1437654c02f8d7e282e5625c820e8050add0.png)  
But I’m seeing this error in my browser console:  
 ![image](https://global.discourse-cdn.com/meta/original/3X/3/2/3204361065c6724aa42bbb36b45566ee37f3d1a6.png)  
…and when I look at the site in Matomo, I get this:  
 ![image](https://global.discourse-cdn.com/meta/original/3X/7/1/7175aad3ff327dc18e2bbd9d439b981ad8bd5dea.png)  
What am I missing?

Edit: Further investigation reveals that the error in the Javascript console only appears in Firefox, not in Chrome (with the latest versions of each on a Mac). And I am now seeing some results in Matomo, though Firefox is conspicuously absent–all but one of the visitors are using Chrome; the one exception is using Safari.

---

<div class="post-metadata">

### Author: ![danb35](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@danb35](https://meta.discourse.org/u/danb35)
#### Post date: [November 11, 2019, 3:03pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/42 "2019-11-11T15:03:55Z")

</div>

Any thoughts on this? This post:

> **[Tracking not working in Firefox](https://forum.matomo.org/t/tracking-not-working-in-firefox/24552)**
>
> I am facing the same problem…I am using 53.0.2. I removed all history, cookies and cache… Didn’t work for me.

suggests that it could be Firefox’s “do not track” settings, but even when I disable them for my site, I’m getting the same error in the web console with Firefox. And Firefox doesn’t seem to be viewing this as a tracker in any event:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/8/b8882ea9c998d315512bff7454fe40038a8aae3b.png)

---

<div class="post-metadata">

### Author: ![goaround](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/goaround/32/160650_2.png) [@goaround](https://meta.discourse.org/u/goaround)
#### Post date: [November 13, 2019, 7:37am UTC](https://meta.discourse.org/t/matomo-analytics/33090/43 "2019-11-13T07:37:41Z")

</div>

Try to remove the last / of “[https://www.familybrown.org/analytics/](https://www.familybrown.org/analytics/)” → “[https://www.familybrown.org/analytics](https://www.familybrown.org/analytics)”

---

<div class="post-metadata">

### Author: ![danb35](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@danb35](https://meta.discourse.org/u/danb35)
#### Post date: [November 13, 2019, 10:52am UTC](https://meta.discourse.org/t/matomo-analytics/33090/44 "2019-11-13T10:52:09Z")

</div>

Thanks. Unfortunately, I’m still getting the same error:  
 ![image](https://global.discourse-cdn.com/meta/original/3X/2/1/21b20735ac936728723c4dffb18686ccf081d72d.png)

---

<div class="post-metadata">

### Author: ![goaround](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/goaround/32/160650_2.png) [@goaround](https://meta.discourse.org/u/goaround)
#### Post date: [November 13, 2019, 2:52pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/45 "2019-11-13T14:52:02Z")

</div>

Could you give me the URL of your forum?

---

<div class="post-metadata">

### Author: ![danb35](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@danb35](https://meta.discourse.org/u/danb35)
#### Post date: [November 13, 2019, 8:15pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/46 "2019-11-13T20:15:31Z")

</div>

> **[SpareOom](https://talk.spare-oom.com/)**
>
> SpareOom is a forum for discussion about, or inspired by, the life and works of C.S. Lewis

---

<div class="post-metadata">

### Author: ![eextra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eextra/32/170266_2.png) [@eextra](https://meta.discourse.org/u/eextra)
#### Post date: [January 25, 2020, 9:48pm UTC](https://meta.discourse.org/t/matomo-analytics/33090/49 "2020-01-25T21:48:07Z")

</div>

Do these two fields need to be completed ? I don’t really understand them.

 ![image](https://global.discourse-cdn.com/meta/original/3X/d/e/de72df7efc5b7829ef03bd58944d63ce60c468b0.png)

[Next page](https://meta.discourse.org/t/matomo-analytics/33090.md?page=2)
