Try ERPNext Buy Support Partners Foundation

Google Analytics Website Form Submission Tracking

I would like to start tracking form submissions with Google Analytics/Ads as Goals/Conversions. However it seems forms are currently dealt with in (at least) two different ways.

The built-in Contact and Footer Subscribe Button both seem to use in-line JS using jquery installed in the frappe.ready() method, which calls the frappe.send_message and erpnext.subscribe_to_newsletter methods respectively.

The Web Forms all use the frappe.web_form framework. I have managed to get Google Tag Manager to recognise custom events on a single Web Form using the code below in the Client Script section of the doctype, but there doesn’t seem to be an obvious way of tracking form submissions across the whole site. Since the forms use JS, the normal HTML form submission tracking doesn’t get fired.

Am I missing something, is there a plan to make form submission consistent and trackable, and does anyone have any jquery code to install via frappe.ready to track the built-in public forms in the Website Script section please?

The only other simple way I can see is to track <button> element clicks.

frappe.web_form.after_save = () => {
    dataLayer.push({'event':'FormSuccess'});
}

TIA!

2 Likes

very interesting!

you can use GTM to tracking the form.

Since forms are not handled as standard form POSTs, an example would be useful