While talking with marketers, we noticed that one of the most popular topics among them is form tracking. In this blog post, we’ll show you how to use Google Tag Manager (GTM) to track your Qualifio form submissions in Google Analytics.
Prerequisite: Your GTM tag needs to be present in the Tags of your Qualifio campaign.
Tag + Trigger
Since you are interested in form tracking, you are probably already familiar with the main GTM concept: every interaction you want to track needs a tag and a trigger. If you want to track form submissions with Google Analytics, you’ll need to create a Tag and a Trigger (rule) when a tag must fire. Creating a tag is the easy part of this process. Let’s make one!
- Go to Tags
- Press New button
- In Tag Configuration choose Google Analytics – Universal Analytics:
- Choose Track Type – Event
- Event Category – Qualifio form submission (feel free to choose another appropriate title)
- Event Action – Qualifio contact form (feel free to choose another appropriate title)
- Leave the Event Label part empty (for now). We’ll get back to it later.
- Google Analytics settings – Select or create your Google Analytics Settings Variable.
- Leave the Triggering part empty (again, for now). We’ll get back to it later, too ;)
- Click Save.
In this section, we’re going to enable Tag Manager to capture campaign titles.
var title = document.getElementsByClassName("campaign_title").textContent;
This code is ready to use. Copy and paste it in your variable. Take a look at the screenshot below to see what we’re talking about:
Done! Save the variable, go back to the tag you previously created and select your new variable as Event Label:
Create a custom event trigger
In this section, we’re going to create a form submit trigger.
The first thing we need to do here is to inspect the submit button of a form. We’ll need to find a way how to instruct Google Tag Manager which particular element we are interested in. Before you submit the form, right-click on the submit button and choose Inspect Element.
You will then see the browser’s developer tools that contain various information about the element: its content, CSS class, etc. In the example below I see that the button has an id called “register” which could be used as a condition in the click trigger.
Check variables are set up to allow click ID tracking
- Go to Variables
- Click Configure
- Scroll down to Clicks
- Check the Click ID variable
- This step is autosaved
Set up click ID trigger
- Create a new trigger by clicking Triggers in the left sidebar and then New
- Give the trigger a name – for instance, “Qualifio form submit”
- Select type Click - All Elements
- This trigger fires on Some Clicks
- Select Click ID in the field to the left, set the middle field to equals, and type register in the field to the right.
- Click Save.
Finish setting up your tag
- Go back to your tag by clicking Tags on the left sidebar
- Scroll down to the second box and click to choose the trigger
- Set it to fire on the “Qualifio form submit” trigger that you made earlier
- Click Save.
This is where the fun starts now that all the groundwork is done. Now we just need to check if the tag works properly.
One of the brilliant things about Google Tag Manager, is the ability to preview everything you’re doing – including the triggering of clicks.
Click Overview in the left menu to get back to the home screen. Then click Preview.
Go to your campaign, where Google Tag Manager is installed. You should see the Google Tag Manager preview in the bottom half of your window.
Test your configuration with GTM’s Preview mode. You should see the tag being fired when you submit the form.
If you want to check that the event is transferred to your Analytics dashboard, visit your Analytics account.
Click Real-time > Events
Go to your campaign in another window, submit the form, and then go back to Analytics. There should be an event triggered within Analytics. In the “Event Label” column you should see the title of the campaign where the form was submitted from.
Please note that this tracking rule will automatically be applied to all identified Qualifio campaigns that contain your GTM tag. Indeed, once a button with the id “register” will be detected, the event will be reported in Google Analytics each time the button gets clicked on.
Once everything looks as you expect, go ahead and publish your updated GTM container. This is very important.
- The objective here was to create an event in Google Analytics whenever a participant submits a form and thus creates or updates their profile. This technique is applicable to many other types of conversion.
- This technique causes a tag to fire every time a form in a Qualifio campaign is submitted. This example assumes the submit button contains a “register” ID attribute. We can thus use this ID to create a trigger that will listen for when this form is submitted.