Let Matomo recognise traffic from Mastodon as coming from Mastodon instead of 'Direct entry'

I am currently involved in launching a new site that uses Matomo for its analytics and that will have an accompanying Twitter and Mastodon feed. At the moment all traffic coming from posts on Twitter is recognised as coming from Twitter and classified under ‘Social network’ but traffic coming from Mastodon is considered a ‘Direct entry’ and not classified under ‘Social network’.

I understand that Twitter traffic comes from twitter.com or t.co whereas Mastodon traffic can come from any domain that runs a Mastodon server. That makes Twitter traffic much easier to identify.

Would it be possible to make Matomo correctly identify Mastodon traffic?


There are two issues with detecting Mastodon traffic in Matomo:

On one hand there is no one canonical URL as there is an endless amount of Mastodon domains. Of course one could circumvent this by listing a bunch of the most popular instance domains
(which is in fact what Matomo does)

But the other issue is that Mastodon is intentionally not setting the referrer URL to protect the users privacy.

You can see e.g. that on https://mastodon.social/@LeonardoDiOttio/108765723092232754 the link to this forum post has a rel="noopener noreferrer" attribute. And it is the same for the links from the Mastodon UI.

1 Like

OK, thanks. There was some discussion over on Mastodon already about how the referer is disabled.

Is that the reason that the list you pointed at is actually not consulted as Matomo never gets to know the URL? In our situation I see traffic not being recognised that I know is coming from one of those domains.

If a HTTP referer would be passed on, perhaps with the URL stripped but with a header such as “source=mastodon” added, would that help?

P.S. For what it’s worth, there are a number of global top 15 Mastodon servers (https://mastodon.fediverse.observer/list) missing in that list, probably because it was last updated two years ago. The following are all fairly big now:

1 Like

Does anyone know this? If a custom HTTP Request Header were to passed on by the Mastodon servers, web clients or apps, for example “Source: Mastodon”, could Matomo easily be extended to look for those headers and classify that traffic as such?