> For the complete documentation index, see [llms.txt](https://docs.adpage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adpage.io/integrations-websites/woocommerce/generate_lead-datalayer-contactform7-and-gravityforms.md).

# 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.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FaMneid686Z780GEwYsuw%2Fimage.png?alt=media&amp;token=3ff8af11-1903-4ebc-a770-fffe3ea237ed" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FopnxWJ2y3ORzVsxUo71d%2Fimage.png?alt=media&amp;token=a22aec0a-e9d8-45b5-b0f2-09dcb1316627" alt=""><figcaption></figcaption></figure>

#### 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.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FhWx5SEKxpnHEL2gf43HG%2Fimage.png?alt=media&amp;token=593f5248-6b45-4fd4-a37b-7370775442df" alt=""><figcaption></figcaption></figure>

**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.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FN6go3HVWDRosIy8zqA79%2Fimage.png?alt=media&amp;token=af0c4581-1c8e-4b2c-bc02-521a0d74d15f" alt=""><figcaption></figcaption></figure>

**3. Add the parameter to your GA4 tag**

Save the variable, reopen your GA4 event tag, and add a new event parameter:

| Parameter name            | Value                       |
| ------------------------- | --------------------------- |
| `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.

<figure><img src="https://1274044937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FA65KwL1NwewlJbtCXsXd%2Fuploads%2FNnYJL3aahcWvSRzowAc6%2Fimage.png?alt=media&amp;token=03f63755-bd75-4bdb-9c43-c54ea34bba1d" alt=""><figcaption></figcaption></figure>

**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`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.adpage.io/integrations-websites/woocommerce/generate_lead-datalayer-contactform7-and-gravityforms.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
