Triggering a web analytics tracker code for direct dload

Hello all,

I’m new here, but I’ve been using the amazing Sparkle for a while and it helped us create our website and be in control of how we manage it. However, I’m by no means an expert when it comes to web development and I’m trying to do something but I might be overthinking it.

I’m using Matomo (web analytics) on my own server to provide me with insights on what’s going on with our website. With Matomo (as I believe it is with others), I add a tracker to the website and all is working well so far with one exception…

I have a simple brochure in PDF that one can dload by clicking on a button on the website. Modern browsers default to opening the file in a new window. However, I’ve configured Apache to force the dload of the brochure and it works fine.

The problem:
If someone visits the website and clicks the button to dload the brochure, Matomo will track this as a dload. However, if someone goes directly to the dload link, it seems like Matomo does not know about it (I believe because the tracking code was not executed).

I like my way of doing it because I can create a QR code and people can scan it and dload the brochure without going to the website if they wish. This was very useful during and expo where we had a booth and showed a nicely printed QR code for this purpose. However, I don’t know how many dloaded the brochure directly (while I know about the visits to the website that clicked to dload the brochure).

I’m not sure how to accomplish this and if there’s a simple way of doing it.

Thank you for your help and any suggestions in advance :slight_smile:

hey darklight, welcome!

Okay, cool. So, what matomo does is track a webpage and every event that happens within it. It loads and start tracking the moment someone starts that page event.

A QR Code is a direct link, as you yourself have said. For this kind of use, you won’t be able to use matomo without linking the person directly into the page event where matomo is tracking.

What you can do it, for those QR Codes, you generate a bit.ly link which will give you everything you’re looking for (how many people used the QR Code = downloaded the brochure).

tl:dr - matomo doens’t track specific links, it tracks specific pages and whatever happen inside. Use an URL shortener or similar to track stuff within a specific link and you’ll be fine!

1 Like

Thank you @primo. That’s “thinking outside the box” :slight_smile:

What a great idea. Why didn’t I think of that :slight_smile:
I can’t believe I missed it, especially that I self host Shlink (a URL shortener). Now that you mentioned the idea I remembered this feature in Shlink.
Now everything stays within my servers. So no Google analytics and now Shlink for the downloads.

Thanks again for the tip :slight_smile:

1 Like