Problem with setRequestMethod POST (due to mod_security)

Due to mod_security we have added the _paq.push([“setRequestMethod”, “POST”]); to the tracking code. Most of the time this is working fine, but still with some visits the GET method is used, and therefore no information stored in the piwik database.

Normally the apache logfile shows lines like “POST /piwik/piwik.php HTTP/1.1” 200 404 “​http://www.domain.nl”. Some lines from the apache logfile: “GET /piwik/piwik.php?action_name=pagename…” even on the same html page!

I am not able to reproduce only wittness this from happening. Thanks for any help possible! Running Piwik 1.12 on Apache, systemcheck reports “There are no problems with your Piwik setup”, the tracking code:


<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(["setRequestMethod", "POST"]);
  _paq.push(["trackPageView"]);
  _paq.push(["enableLinkTracking"]);

  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.domain.nl/piwik/";
    _paq.push(["setTrackerUrl", u+"piwik.php"]);
    _paq.push(["setSiteId", "2"]);
    var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
    g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- Piwik Image Tracker -->
<noscript><img src="http://www.domain.nl/piwik/piwik.php?idsite=2" style="border:0" alt="" /></noscript>
<!-- End Piwik -->

Maybe this only happens for a particular browser which could indicate a browser bug? otherwise i’m not sure…

Found a option to reproduce quite easily: run the html from a local webserver or even better as a file (file > open > name-of-file.html)
This breaks the coding for making a Post request to the webserver and runs a GET request sadly.