Google Tag Manager's gtm.formSubmit not firing for AJAX forms

Tag: google-analytics , google-tag-manager Author: hy586 Date: 2013-10-26

When I create a tag to listen for form submissions using Google Tag Manager.

For my ajax submitted form which does not go to a new page, the submission of a form does not fire the gtm.formSubmit event into the data layer.

What should I do instead?

I need a "codeless" solution to detect form submission and to capture the submitted values.

Best Answer

I have an ajax submitted form and the formSubmit click listener and event tags are working for me.

You might be doing this already, but just to double check;

  • You are adding 2 tags - the formSubmit listener and the Analytics event tag for that event?
    • Are you setting up the filters correctly (i.e. including event equals gtm.formSubmit, and the appropriate page?)

If it still isn't working, another suggestion is to use a simple click listener, then filter for both the page the form is on and the id of the submit button.

Other Answer1

Here is how Google recommends doing it.

  1. Add a basic page tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Page View) if you don't already have one. This tag must fire on all pages.

  2. Add a tag of type Event Listener > Form Submit Listener. You can name it “Form Submit Listener”. Add a single firing rule of "All pages", or, for the specific page(s) on which you want to listen for form submissions.

  3. Add a rule (named "Form Submit" for example) with the following condition: {{event}} equals gtm.formSubmit

  4. Add an Analytics event tracking tag (i.e. Tag Type of Google Analytics or Universal Analytics; Track Type of Event). Add the rule you created in the previous step as the firing rule (for example, "Form Submit"). Enter a Category, Action, and and Label for the event. For example, you might use the following: Category "Forms" Action "Submit" Label "Lead Gen".

  5. Save a version of the container and publish it.

Other Answer2

I ran into another potential reason for this as well and thought I'd drop it in here.

In the Form Submit Listener, you need to have Check Validation unticked for AJAX forms (if the Submit button is blocked from doing a normal submit, as you would do with AJAX forms, this option blocks the listener from firing the correct event).