How to Create a GTM Trigger to Monitor File Uploads in Gravity Forms on Your WordPress Site

In this tutorial, we’ll show you how to track file uploads in Gravity Forms and send the data to Google Analytics.

But first, let’s start by defining what a trigger is. In Google Tag Manager, a trigger determines when and where a tag will fire. A basic trigger requires a condition, such as a specific URL, to activate. Once the trigger is activated, the tag will fire, and the data is sent to Google Analytics.

Now, let’s jump into the steps for creating a trigger in GTM.

Step 1: Create a Trigger Type

First, log in to your GTM account, create a new trigger, and select Trigger Type.

Step 2: Select Custom Event Trigger

Next, select the Custom Event option and name the trigger appropriately.

Step 3: Add JavaScript Code

The next step involves adding some JavaScript code so that the trigger can track file uploads in Gravity Forms. The code should look like this:

<script>document.addEventListener( 'gform_confirmation_loaded', function( event ) {
if (event.detail.forms && event.detail.forms.length) {
var formId = event.detail.forms[0].id;
var filename = event.detail.forms[0].uploadedFiles;
'event': 'gravityFormFileUpload',
'formId': formId,
'filename': filename

This code listens for the `gform_confirmation_loaded` JavaScript event, which is triggered when a Gravity Form is successfully submitted. It then sends the form ID and name of the uploaded filename to the data layer upon submission.

Step 4: Set Trigger Criteria

Now, let’s set the trigger criteria. We want the trigger to fire only when a form is successfully submitted with a file upload. In the Triggering section, select the Trigger Configuration drop-down and choose Custom Event. In the Event Name field, enter `gravityFormFileUpload`.

Step 5: Save and Publish

Click Save to save your trigger, and then publish your changes.

Step 6: Check Your Results

Now that you’ve set up your trigger, you can check if your setup is working by testing a file upload form submission. Go to your website and submit a form with an attached file. When you submit the form, look at the data layer and make sure that the file name is sent to Google Analytics. To do this, open Google Analytics and check the events under the “Real-Time” tab; you should see the `gravityFormFileUpload` event with the form ID and file name.

Congratulations, you’ve now successfully created a trigger to monitor file uploads in Gravity Forms on your WordPress site!


Google Tag Manager triggers allow marketers to track specific events on their website and send relevant data to their analytics tools. With the right setup and configuration, you can quickly monitor and analyze user behavior to optimize your website’s performance. We hope you found this tutorial helpful in creating a GTM Trigger to Monitor File Uploads in Gravity Forms on Your WordPress Site.