Automatic creation of forms

I’m using matomo cloud, and it seems that the automatc detection of my forms is not working.

I have currently 4 forms listed, but when visiting a page with an unlisted form, the latter is not added in matomo.

Also, in the settings page for form management, it is mentioned that the system is currently confgured to automatically create up to 3 forms, of which 2 have been created so far. Where can I change “3” into something bigger? I am allowed to create 100 forms if I read it correcltly…

any suggestions ?

Hi @pieter
Can you share your form configuration in Maotmo admin? (with screenshot)
Also, how do you track pages? (JavaScript, MTM, HTTP, server log, etc.)

Hi,
This is the message:

Pages are tracked by the matomo snippet:

var _paq = window._paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="https://xxxxx.matomo.cloud/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.async=true; g.src='//cdn.matomo.cloud/xxxxxx.matomo.cloud/matomo.js'; s.parentNode.insertBefore(g,s);
  })();
});

Hi @pieter
Are you sure your page has HTML <form> tag? and fields within this tag?

(I missed this part of your initial message)
For this particular need, contact your Matomo Support team by email.

Actually, you made a good point there. It is a hubspot page, and Hubspot loads the forms with javascript.
There are events when the form is ready, is there something I can trigger at that point in time in the event handler?

Hi @pieter
After the javascript put forms, you could do as described there:
https://developer.matomo.org/guides/form-analytics/reference

Thx, I have confirmed that the event is handled and that at the time I call scanForForms is called, the form element is present in the DOM. But still, no new forms are added in my forms list in matomo.

if(event.data.type === 'hsFormCallback') {
     if (event.data.eventName === 'onFormSubmitted') {
       _paq.push(['FormAnalytics::trackFormConversion', ,'hsForm_' + event.data.id]);
     } else if (event.data.eventName === 'onFormReady') {
       _paq.push(['FormAnalytics::scanForForms']);
     }
   }

For existing forms (added manually in the matomo admin interface) the conversion tracking works. In the case for ‘onFormReady’, i have logged to the console the list of getElementByTagName(‘form’) and the list was not empty before adding he scanForForms to the async matomo handler. So I’m not sure now why the form is not showing up in the matomo backend automatically.

Thanks by the way for your help, it has been very useful so far!

Kind regards
Pieter

Hi @pieter
Can you check isFormAnalyticsEnabled()?
https://developer.matomo.org/guides/form-analytics/reference#isformanalyticsenabled

hi @heurteph-ei , sorry for the delay, i had some holidays. I think it is enabled, but I’m not sure how to check. In order to make sure it is, I changed the code as follows:

var _paq = window._paq || [];
  window.addEventListener('message', event => {
   if(event.data.type === 'hsFormCallback') {
     if (event.data.eventName === 'onFormSubmitted') {
       _paq.push(['FormAnalytics::trackFormConversion', ,'hsForm_' + event.data.id]);
     } else if (event.data.eventName === 'onFormReady') {
       console.log('start scan for forms');
       _paq.push(['FormAnalytics::enableDebugMode']);
       _paq.push(['FormAnalytics::enableFormAnalytics']);
       _paq.push(['FormAnalytics::scanForForms']);
     }
   }
});

Doing so should make sure that it is enabled in any case no? Stll the form is not detected.

kind regards,

Pieter

Hi @pieter
In order to check if this is enabled or not, you have to do code such:

Matomo.FormAnalytics.$methodName()

(before, check the existence of Matomo and Matomo.FormAnalytics object and Matomo.FormAnalytics.isFormAnalyticsEnabled function).

As you use Matomo Cloud, I think you’ll get better help from the Matomo support by email…