Tracking Form Submissions
How to add CAPI Facebook Tracking a lead form submission using GTM and Deviate Tracking
Tracking lead forms is extremely important, and Deviate Tracking allows you to track any type of form, whether it’s an inbuilt shopify newsletter subscription, a contact form 7 or ninja form wordpress opt in box or even an unbounce lead form.
Ensuring GTM is installed
Google Tag Manager (GTM) should already be installed ont the website or web application before adding CAPI Facebook Tracking. To install GTM onto any website or web application, please follow this walkthrough. This walkthrough also helps you ensure that GTM has been successfully installed.
Setting up Deviate Tracking Variables
The next step is to configure the necessary Deviate Tracking variables in GTM by following this quick tutorial. Preconfiguring the Deviate Tracking variables before continuing with installation will save time and reduce mistakes.
Selecting your Form Element
The first step to tracking a lead form submission, is getting the element ID or class name of the form to be tracked. Navigate to the lead form’s page and right click on the form > click “Inspect” or “Inspect Element.” The shortcut to Inspect Element on the browser being used may also be Command+Option+i or F12 depending on your operating system and browser.
Once this is done, the Inspect Element tool will appear and the lead form code should already be selected. Otherwise, or to double-check that the correct code is selected, look for the line that begins with ‘<form’
To specify GTM to track this form specifically, find the class or element ID attribute within the same line of code. This attribute is either shown as id=”leadForm”, or class=”leadForm.” In the case of this example, the Form ID is equal to “test,” and the Form Class is equal to “wpcf7-form init”
The form will usually have either this ID or Class attribute set to identify this specific instance. If, in any case, neither of these HTML attributes are present then this tracking method will not work. Deviate Tracking recommends contacting the site’s developer for advance help or making a request to add a form ID or Class Name attribute to the form.
Once the form’s ID or Class Name has been identified, the Trigger within GTM can now be configured.
Creating a Trigger
Firstly, within GTM, create a Trigger so that the Deviate Tracking Tag fires accordingly on the website. Within GTM’s Workspace, find the Triggers option in the left-hand side menu. Click ‘New’ to start configuring the Trigger to track the form.
[Image of ‘New’ button in the Trigger section of Workspace]
Click on Trigger Configuration and choose the Form Submission trigger type.