In this guide you will learn how to get Form Analytics to automatically track your website's online forms.
/piwik.js as long as the file
piwik.js in your Matomo directory is writable by the webserver/PHP.
To check whether this works by default for you, login into Matomo as a Super User, go to Administration, and open the "System Check" report. If the System Check displays a warning for "Writable Matomo.js" then learn below how to solve this.
Matomo detects and starts the tracking of your forms automatically if they have set a form
name or a form
id attribute like this:
<form name="cloud_login">...</form> <form id="cloud_login">...</form>
If your form does not have any of these attributes, we recommend setting such an attribute. If you can neither set a form
nor a form
id, you will still be able to track the form if there is only one form on your page. To track such a form go to
"Administration => Forms" and create a new form. There you can define one or multiple pages that you want to track into this
newly created form.
If your form or field names change randomly, can also define a form name by using the
data-matomo-name (recommended) or the
data-piwik-name attribute like this:
Similarly you can define a readable name for your fields like this:
<input data-matomo-name="username" type="text">
Note that in Matomo Form Analytics itself you can give a readable name to any form or any field. If your form has for example a field named "input_4",
you can map this field name to a human readable name like "Username" directly in the Matomo user interface.
You don't need to set a
data-matomo-name or a
data-piwik-name in this case.
If you do not use a
<form> element to mark your forms, you can specify a
data-matomo-form (recommended) or a
data-piwik-form attribute on any element
to let Matomo know that this element contains a form. Matomo will then discover this form and all fields automatically.
<div data-matomo-form data-matomo-name="cloud_login"> <input name="username" type="text"> </div>
Read more about this in the Form Analytics API Reference.
If you do not want a form to be tracked, you can specify a
data-matomo-ignore or a
data-piwik-ignore attribute on your form like this:
<form name="cloud_signup" data-matomo-ignore></form>
If set, it will not even send any tracking requests for this form to your Matomo. This is useful if you want to exclude for example forms that are shown on each page like a search or a newsletter sign up form.
piwik.jsin your Matomo directory file is not writable
piwik.js is not writable
piwik.jsfile writable, for example by executing
chmod a+w piwik.jsor
chown $phpuser piwik.js(replace
$phpuserwith actual username) in your Matomo directory. We recommend running the Matomo console command
./console custom-piwik-js:updateafter you have made the file writable.
Yes, there are:
piwik.jsever becomes writable, the FormAnalytics tracker would be loaded twice (in such a case the tracker notices it was already initialized and won't track everything twice)
If possible, we recommend making the
piwik.js file writable.