How do I enable tracking for visitors when JavaScript cannot be used on a page (or for Visitors that have disabled Javascript)?
Sometimes it is not possible to use the standard Matomo Analytics JavaScript Tracker in your app or websites. For example:
- you have a site hosted on WordPress.com with a Free, Personal or Premium plan and can’t add JavaScript
- to track visitors who have JavaScript disabled
- to track how often pages are viewed on a website you don’t control and won’t allow you to include JavaScript code in their pages (such as Ebay or other third party marketplaces).
- to track your newsletter emails opened rate
With Matomo you can still enable tracking of visitors when JavaScript cannot be used, using the Matomo Image Beacon.
You can include an image in your web pages, the image simply being a reference to the Matomo Tracking API endpoint, and Matomo will collect data about your users. Here is what the image looks like:
<!-- Matomo Image Tracker -->
<img src="https://matomo.example.org/matomo.php?idsite={$IDSITE}&rec=1" style="border:0" alt="" />
<!-- End Matomo -->
In this example above, replace {$IDSITE}
with your Matomo website ID, and replace https://matomo.example.org/
with your Matomo URL.
The following parameters can be passed to the image URL:
- rec – (required) The parameter &rec=1 is required to force the request to be recorded
- idsite – (required) Defines the Website ID being tracked
- action_name – Defines the custom Page Title for this page view
- urlref – The Referrer URL: must be set to the referrer URL used before landing on the page containing the Image tracker. For example, in PHP this value is accessible via
$_SERVER['HTTP_REFERER']
- idgoal – The request will trigger the given Goal
- revenue – Used with idgoal, defines the custom revenue for this conversion
- bots – Set
&bots=1
to track all requests to the tracking image, including from bots and robots - and more! – There are many more parameters you can set beyond the main ones above. See the Tracking API documentation page.
Note: this image tracking code does not use Javascript and is not able to create first party cookies, so Matomo will not be able to track some user information, learn more in When tracking visitors using an image beacon instead of the JavaScript tracker, what are the differences?
Enable Tracking for visitors who have JavaScript disabled
When you use the standard Javascript Tracking Tag, Matomo (Piwik) will only track visitors with Javascript Enabled in their web browser. You can configure Matomo to also track users who have disabled Javascript: to do so, edit the Matomo Tracking Tag and add a <noscript>
element which includes the Image beacon:
<noscript><p><img src="http://matomo.example.org/matomo.php?idsite=1&rec=1" style="border:0" alt="" /></p></noscript>
After making this change, visitors with disabled Javascript will execute the noscript and will load the matomo.php image and will have their traffic recorded in Matomo.
Using Server-side Tracking or Log Analytics
In some cases tracking using an image tracker might not be the best option for your website or app. In these cases you can still implement tracking using Server-side tracking or alternatively with Log Analytics using your web server logs