Is Form Analytics required to track form submissions?

I’m wondering if Form Analytics is required to track successful form submissions?

Or is there another way?


You can write your own basic Form Analytics with Event Tracking.

Just track an event in javascript when the form gets submitted. Of course if your form redirects the user to a target page it is event easier as you just need to setup a goal for users visiting this page.

I don’t seem to be getting any output in the Events area of the Dashboard. Perhaps I’m doing something incorrectly?

I’ve added the following to my <script> block below the Piwik tracking code :

const form = document.querySelector('.my-form');
form.addEventListener('submit', () => {
  _paq.push(['trackEvent', 'MyFormSubmitted', 'submit']);

And the following HTML:


I don’t know what I can try to troubleshoot…

PLease check if a) the eventlistener is correctly assigned to the form event and b) check the firebug / chrome network if the request is being sent on form submit (enable the checkbox “preserve log” to keep the request stored in the list).

Perhaps the submit event of the form loads too fast and there is no time to finish the “trackEvent” request. Therefore, you can implement a short timeout (150ms or so) to provide some time for the request to finish before the dom unloads.

Good tip about the Preserve log checkbox!

I’ve verified the evenlistener is being assigned and triggered on a submit event (with a console.log).

I can also see that the following query string parameters are being sent (along with a bunch of others):

:path: /piwik.php?e_c=MyFormSubmitted&e_a=submit&...

I’m not sure where to add the short timeout.

If the request fires, there should be data tracked in Piwik. Have a look at the visitor log to check if the submit event was captured. There is a “blank” before the string “MyFormSubmitted” - probably, you should trim that as well.

Please check in the network tab if the request was finished before dom unload. console.log is triggered instantly, so we can’t tell if the request went through to Piwik.

You only need the timeout if the dom unloads before the request to the tracking server was finished (you can see that in the network tab as “aborted”).

1 Like

The blank was from a bad copy/paste, but thanks.

I appreciate your help with troubleshooting… the culprit has been located however. It seems another person had enabled the following in the Manage Settings…

Only track visits and actions when the action URL starts with one of the above URLs.

The “above URLs” being our production server. Obviously, localhost and our dev URLs were not being captured and tracked.

Thanks all!