Form Analytics identification of forms : identifier precedence

Hi,

We’re currently integrating the form analytics feature into our website, and the issue is that the website is not controlled by us, and we are not allowed to modify / adapt the HTML id and / or the name attribute. If we instead set a data-matomo-name attribute according to your docs, but while the same form element also has both an id and a name attribute, will the data-matomo-name attribute be considered before name and id automatically? Or do we have to configure this explicitly in some other way you may recommend?

Thanks in advance!

Hello @fulstadev

As long as you’re able to get the name or id of the form, Matomo will be able to track it, For more insight, please see this guide: https://matomo.org/faq/form-analytics/faq_23744/

However, if there is no option for you to manage the website and If your form or field names change randomly, I wouldn’t recommend the plugin.

Hello @Emerson_N I don’t think that you understood my question, let me rephrase it: If I have a HTML form on my page whose id and / or name attribute frequently change and I have no control over the id and / or name attribute value over time. Am I still able to use your form analytics feature if I use a data-matomo-name attribute on the concerned HTML form tag?

In other words: If a HTML form tag has all three, an id, a name and a data-matomo-name HTML attribute: which one of them is used to identify the form in your matomo account? That is what I mean by identifier precedence.

Because, if your attribute precedence is let’s say data-matomo-name > name > id (= your matomo js script first checks for the attribute data-matomo-name; if it doesn’t exist, it checks for name, and if that one doesn’t exist, it checks for id, …). In that case a changing value for the name and / or the id attributes on my form tag wouldn’t matter as long as the data-matomo-name HTML attribute on the concerned form tag stays the same. You see what I mean?

Hi @fulstadev ,

data-matomo-name attribute takes precedence over name attribute as per our devs.

1 Like

@karthik and it also takes precedence over id?

Hi @fulstadev ,

Form analytics will look at form name to start with rather than id attribute, if data-matomo-name is present then it will take precedence over name, so adding this attribute is suffice in your use case. If you have any issue, please update us we can investigate further

@karthik so I guess the precedence is data-matomo-name > name > id then ?

Thanks!

1 Like

@karthik Actually nothing is getting tracked, even after adding the data-matomo-name HTML attribute to the concerned form tag and all of its form fields as explained here. Can you explain what else is needed?

Matomo’s UI says that only up to three forms are automatically tracked with the matomo.js, which is the case on the concerned website already (3 forms have been auto-detected, and one of the three is one automatically identified via the name attribute, which however randomly changes, hence assigned the data-matomo-name to its form tag). After adding the data-matomo-name HTML attribute to the concerned form tag and all of its form fields, how do I add that form into Matomos Form Tracking? In the Matomo UI, when adding a new form, I can only select among ‘form name’ and form id’; there is no ‘data-matomo-name’ option in the UI of Matomo’s Form Analytics feature used to add form tracking?? Is it maybe better to use js for everything, even for registering the form’s tracking, e.g. via trackForm explained in your docs on https://developer.matomo.org/guides/form-analytics/reference#trackformconversionnodeorformname-formid ? And forget about the addition of the form to be tracked via the Matomo UI alltogether?

I am also facing the same problem on my site please tell me a proper solution so I can fix the forms on my site.

Hi @fulstadev , @kirk ,

Please get in touch with our support team at shop@matomo.org