What is an Ajax form? It is a form that, when submitted, does not reload the page. Instead, an Ajax form runs in the background, which is great for user experience. However, it can also create challenges when it comes to event tracking in Google Analytics (GA).

The problem:

There are a couple ways web managers often track form submissions as events, but the most common is tracking when a confirmation or thank you page is displayed. But with Ajax forms, there is no confirmation page. So how do you track the form was submitted?

The solution:

Start by determining a standard naming convention before creating tags and triggers for your site. This will help when there are hundreds of tags, and is just good practice in the long run.

Then, you’ll need to set up a trigger—specifically, the “form submission” trigger type in Google Tag Manager (GTM). Ensure that you have selected the “wait for tags” box. This will delay the form submit until all the tags have been fired and give it a max wait time for the tags to be fired or timeout.

You’ll also want to select the check box for the check validation. This will make sure the submission is successful before firing the trigger. If the form is only on one page then in the next section select Page URL, contains, and then part or the entire URL. This will force GTM to listen for a form submit on the specific URL.

Below is a screenshot of setting up the trigger to get you started:

 

 

Now that your trigger has been set up, it’s time to take care of the tag.

Depending on the type of GA you have setup, select either Universal Analytics or Classic Google Analytics (you will need to know your Google Analytics ID). Thereafter, select “Track Type of Event.”

You’ll need to fill out the event tracking parameters. Here’s what that might look like:

 

 

After you fill out the event tracking, select the trigger we created earlier; once selected click, simply click save and then publish.

After the tag is published, be sure to test the form and check to make sure the event is triggered in GA under Real Time and Events.

Once you see the event is working your job is done! Woohoo!