This guide shows you how to set up and configure Google Analytics 4 (GA4), Google Tag Manager and Contact Form 7 on your website.
Before you begin
This guide assumes that you completed the following:
- Have created Google Analytics account and property.
- Have created a Google Tag Manager account for your site.
It also assumes you have the following:
- Access to Google Tag Manager container for the website
- The Editor (or above) role in the Google Analytics account
Google Tag Manger setup
Make sure that you have access to your GA4 Measurement ID (e.g., “G-XXXXXXXXX”), if you need help, here’s how to find your Measurement ID. To start we’ll be on the Tags page in Google Tag Manager.
This is a preview of what the final setup will look like:

Tag: GA4 – Configuration
- Click Tags in the left side navigation.
- Click New.
- Click Tag Configuration.
- Select Google Analytics: GA4 Configuration.
- Enter your Measurement ID (how to find your Measurement ID)
- Leave “Send a page view event when this configuration loads” checked.
- Click Triggering.
- Select Initialization – All Pages.
- Name the tag GA4 – Config.
- Click Save.

Variable: CF7 – Form ID
This is optional, but if you have more than one variation of forms on your website, you can use the formId variable to see them reported on individually. For example, if you have a request a quote form and a contact form, you can see how many times each of them was submitted.
- Click Variables in the left side navigation.
- Click New in the User Defined Variables section.
- Click Variable Configuration.
- Select Data Layer Variable under Page Variables in the Choose variable type menu.
- For the Data Layer Variable Name enter formId
- In the top left update the name from Untitled Variable to CF7 – Form ID
- Click Save.

Trigger: CF7 – Submit
- Click Triggers on the left side navigation
- Click New.
- Click Trigger Configuration.
- Select Custom Event.
- For the Event name enter cf7submission
- Leave This trigger fires on All Custom Events selected.
- In the top left, update the name from Untitled Trigger to CF7 – Submit
- Click Save.

Tag: HTML – CF7 Submit Listener
- Click Tags in the left side navigation.
- Click Tag Configuration.
- Select Custom HTML under Custom in the Choose tag type menu.
- In the HTML box enter:
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
window.dataLayer.push({
"event" : "cf7submission",
"formId" : event.detail.contactFormId
})
});
</script>
- Click Triggering.
- Select All Pages in the Choose a trigger menu.
- In the top left update the name from Untitled Tag to HTML – CF7 Submission Listener
- Click Save.

Tag: GA4 Event – Form Submit
- Make sure you’re on the Tags page.
- Click New.
- Click Tag Configuration.
- Select Google Analytics: GA4 Event.
- For the Configuration Tag select the GA4 – Config tag you made earlier.
- In Event Name, enter “generate_lead“, without quotes. This is the recommended name to use when a user submits a form or a request for information. More about GA4 recommended events.
- Click Event Parameters.
- Click Add Row.
- For the Parameter Name enter form_id
- For the Value field click the button that looks like a Lego brick with a plus icon and select the CF7 – Form ID variable you created earlier.
- Click Triggering.
- Select the CF7 – Submit trigger event you created earlier.
- In the top left, update the name from Untitled Tag to GA4 Event – Form Submit
- Click Save.

Submit Google Tag Manager changes
Your final setup should have 3 tags, 1 trigger, and 1 variable. Your final tag page should look like this:

Note: If you’d like to test your changes you can use the preview mode in Tag Manager to make sure the form submission tag is firing as expected, but that’s out of scope for this tutorial. To submit changes:
- Click Submit.
- Click Publish.
- Click Continue.
Set form submit event as conversion in GA4
Go to the Admin page for your property in GA4 and select Conversions.

- Click New conversion event.
- Enter generate_lead as the New event name.
- Click Save.
