Cannot log PDF download - Matomo returns 406 status

I’m using Matomo 3.13.4 and cannot track a linked PDF download.

Matomo reports other Wordpress (php-generated) page activity completely and correctly as far as I’ve seen. Campaigns (names and keyword) are logged correctly.

But I’m not seeing anything in Downloads, or Goals where I added the PDF filename as a goal.

This is a new, standard (i.e from the regular Matomo download page) Matomo install for a Wordpress site, which I have not used before; I’m normally a Joomla admin. I don’t beieve that this is Wordpress-related.

I captured network traffic in the FF console debugger while accessing the PDF link. I was most surprised to see Matomo return a 406 “Not acceptable” status (below) to the JS tracker. Odd? or normal?

A search of this forum and the broader web did not turn up useful help on this problem.

Below, I have included

  • the link to the PDF file in the html code seen by FF, with piwik_download CSS class
  • the FF debugger’s net log entry for the URL sent to matomo.php, for the original PDF request (Status 406)
  • the FF debugger net log entry for the URL sent to matomo.php, for what appears to be a ping that follows (Status 204) (two seen)
  • My JS tracker code as received by FF

Your suggestions and further questions are appreciated.

Brett

PDF file link, with added Matomo tracking CSS style:

< a class="piwik_download" href="[https://centretownbuzz.com/wp-content/uploads/2020/04/Buzz_April_2020_Final.pdf](view-source:https://centretownbuzz.com/wp-content/uploads/2020/04/Buzz_April_2020_Final.pdf)" target="_blank" rel="noopener">Buzz_April_2020</a>
Status 406 response to JS tracker sending download link (split for readability):
https://matomo.centretownbuzz.com/matomo.php
?download=https%3A%2F%2Fcentretownbuzz.com%2Fwp-content%2Fuploads%2F2020%2F04%2FBuzz_April_2020_Final.pdf&
idsite=1&
rec=1&
r=324270&
h=0&
m=6&
s=0&
url=https%3A%2F%2Fcentretownbuzz.com%2F2020%2F04%2F17%2Fread-the-april-centretown-buzz%2F&
urlref=https%3A%2F%2Fcentretownbuzz.com%2F&
_id=ba45f85071e4a890&_idts=1587419380&
_idvc=2&
_idn=0&
_refts=0&
_viewts=1587424908&
send_image=0&
cookie=1&
res=2560x675&
pv_id=bbskTH
Status 204 (two recorded):
https ://matomo.centretownbuzz.com/matomo.php
?ping=1&
idsite=1&
rec=1&
r=058477&
h=0&
m=6&
s=29&
url=https%3A%2F%2Fcentretownbuzz.com%2F2020%2F04%2F17%2Fread-the-april-centretown-buzz%2F&
urlref=https%3A%2F%2Fcentretownbuzz.com%2F&
_id=ba45f85071e4a890&
_idts=1587419380&
_idvc=2&
_idn=0&
_refts=0&
_viewts=1587424908&
send_image=0&
cookie=1&
res=2560x675&                                                                                                                                                                        
pv_id=bbskTH

JS tracker, sent at end of HEAD:

< script type=“text/javascript”>
var _paq = window._paq || [];
/* tracker methods like “setCustomDimension” should be called before “trackPageView” /
_paq.push([“setCookieDomain”, "
.CentretownBuzz.com"]);
_paq.push([‘setCampaignNameKey’, ‘cxn’]);
_paq.push([‘setCampaignKeywordKey’, ‘cxk’]);
// enable the use of navigator.sendBeacon()
_paq.push([‘alwaysUseSendBeacon’]);
// accurately measure the time spent on the last pageview of a visit
_paq.push([‘enableHeartBeatTimer’]);
_paq.push([‘trackPageView’]);
_paq.push([‘enableLinkTracking’]);
(function() {
var u="//matomo.centretownbuzz.com/";
_paq.push([‘setTrackerUrl’, u+‘matomo.php’]);
_paq.push([‘setSiteId’, ‘1’]);
var d=document, g=d.createElement(‘script’), s=d.getElementsByTagName(‘script’)[0];
g.type=‘text/javascript’; g.async=true; g.defer=true; g.src=u+‘matomo.js’; s.parentNode.insertBefore(g,s);
})();

END

Hi,

A 406 Not Acceptable is rare. I couldn’t find any result for 406 in the Matomo source, so I doubt Matomo is sending it.

But maybe you have set up mod_security, which is blocking requests based on some filter rules that maybe match that tracking request somehow.

1 Like

Thanks. This is a really good theory. It never occurred to me that the server might be returning it. I don’t know why I never thought to check the code itself for a 406 return. Tiredness I guess.

I have never seen a 406 that I can remember in decades of working on webservers. But I normally run VPS, not on the shared hosting that I am dealing with here. So there could well be a protection module in place.

I will inquire with the hosting provider and report back when I resolve this. Thanks Lukas!

Thank you! You identified the exact problem. Bluehost (shared hosting, my personal sites use a VPS) had a mod_security rule that was blocking this matomo tracking request. They removed or changed the rule so that matomo download tracking works now.

1 Like