generate_lead dataLayer (Contactform7 & GravityForms)
Track ContactForm7 and GravityForms with a dataLayer event
AdPage's WordPress plugin pushes a dataLayer event the moment someone submits a Gravity Forms or ContactForm7 form. This guide walks you through turning that event into a clean conversion in Google Tag Manager.
Why bother, if you already track form submissions some other way? Because the alternatives are fragile. Triggering on a CSS element such as a thank-you message, on a generic form submission listener, or on a thank-you page URL all leave room for error: the element changes, the submission fails validation, or someone reaches the thank-you page directly. A dataLayer event fires when the form is genuinely submitted and nothing else. If you have that option, use it.
Setting it up from scratch
1. Create the trigger
In your GTM web container, go to Triggers and create a new one. Choose Custom Event (the orange option) as the trigger type and enter trytagging_generate_lead as the event name. Save it.

The trytagging_generate_lead event is designed to fire only on a Gravity Forms or Contact Form 7 submission, so you don't need any extra conditions.
2. Create the GA4 tag
Go to Tags and create a new tag with Google Analytics: GA4 Event as the tag configuration. Then:
Enter your GA4 Measurement ID, or select the constant variable you already use for it.
Set the event name to
generate_lead. You can use a different name here if you'd rather measure something else.Attach the trigger you just created, and save.

3. Sending visitor data along (for enhanced conversions)
If you want to pass the email address or other details through to GA4 and Google Ads, you first need to know what the plugin actually put in the dataLayer.
1. Test the form submission
Open Google Tag Manager's Preview Mode for your web container and submit your form. Find the trytagging_generate_lead event and open the DataLayer tab, the parameters from your form are listed there.

2. Create a dataLayer variable
In your web container, go to Variables and create a new user-defined variable of type Data Layer Variable. For the variable name, use one of the keys you just saw in preview mode.
In the example above, the key for the email address is form_data.your-email. Yours will depend on the field names in your form, so read them off your own preview output rather than copying blindly.

3. Add the parameter to your GA4 tag
Save the variable, reopen your GA4 event tag, and add a new event parameter:
user_data.email_address
your new dataLayer variable
Any GA4 parameter starting with user_data is formatted automatically so it can be used for GA4 and Google Ads Enhanced Conversions. That prefix is doing real work — don't rename it.

4. Check your changes
Save the tag, open preview mode, and submit the form on your website. You're looking for two things: the GA4 - generate_lead tag firing on submission, and your dataLayer variable actually resolving to a value rather than undefined.
Last updated
Was this helpful?

