Library·SOP·Analytics
Use Google Analytics 4 (GA4) to count one successful Contact Form 7 response as a lead. The GTM4WP WordPress plugin sends Google Tag Manager a small message about the form result and ID; keep what visitors typed out of that message.
Last reviewed: · Editorial review
Clarity, structure and references reviewed in this version. This is not a test in a live account.
Use Google Analytics 4 (GA4) to count one successful Contact Form 7 response as a lead. The GTM4WP WordPress plugin sends Google Tag Manager a small message about the form result and ID; keep what visitors typed out of that message.
This SOP covers:
This does not cover:
GTM4WP is a WordPress plugin that puts a small form-result message in the page's data layer, a behind-the-scenes message that Google Tag Manager can read. This guide uses the successful-send message for the lead event and leaves visitor-entered values out.
Create a note called Contact Form 7 GA4 tracking note with the headings Form and page, Tag Manager, Preview checks, and Live check. Use it to keep the website, container, and stream details for this setup.
Create or open the note and add the four headings. Under Form and page, record the Contact Form 7 form name and the full page address. Leave the numeric form ID blank until step 2.1.
Open Google Analytics, select the intended property, then open Admin > Data streams and choose the Web stream for this site. Check the website address and copy its full Measurement ID (starts with G-) under Tag Manager in your note.
Open Google Tag Manager and select the account and existing Web container used by this site. Copy the container ID beginning GTM- into Tag Manager in your note. On the form page, use Tag Assistant to confirm it detects the same GTM- ID. If the IDs do not match or you cannot tell which container is loaded, ask the site maintainer before editing or publishing.
Turn on GTM4WP's Contact Form 7 data-layer message, while keeping the values visitors type out of it.
In WordPress, open Plugins > Installed Plugins and find Google Tag Manager for WordPress (GTM4WP). If its status is Inactive, select Activate; only then is Settings > Google Tag Manager available. If GTM4WP is not listed, ask your site administrator to install it before continuing.
Before changing GTM4WP's Container code placement, confirm which WordPress tool adds the GTM- container already detected on the form page. Check the active plugins or site settings for Site Kit, GTM4WP, or a header/footer snippet. If you cannot confirm which one adds this exact ID, ask the site maintainer; do not turn off a loader that may be the only one.
In WordPress, open Settings > Google Tag Manager > Contact Form 7. Turn on the Contact Form 7 integration. Set Submitted field values in the data layer to None and keep Also push GA4 recommended events off. This guide sends its own filtered generate_lead tag, so turning on both sources could count the same successful send twice. Save the settings.
Keep exactly one tool loading the connected GTM container. If Site Kit or another confirmed tool already adds this same container, set GTM4WP Container code placement to Off – container code turned off, data layer only. If GTM4WP is the only tool adding it, keep GTM4WP placement enabled and confirm its container ID matches the GTM- ID in your note. Do not add a second loader.
In GTM4WP's Google Tag Manager settings, leave Advanced data layer variable name blank to use the standard dataLayer. If the site uses a custom name, ask the maintainer before changing it.
Also inspect the stream’s GA4 Custom events rules before creating the tag. A rule that derives generate_lead from the thank-you page can overlap with this form-success tag. Record the chosen sender and retire an overlapping rule only with the measurement owner’s approval. Marking generate_lead as a key event applies to every event with that name in the property, including other forms; list those forms in the handoff.
Use the specific GTM4WP message that follows a successful Contact Form 7 send. The general submission message also follows unsuccessful attempts, so use the success message and the chosen form ID.
In WordPress, open Contact > Contact Forms, find the form on your recorded page, and select Edit. In the editor address bar, copy the digits after post= (for example, post=274) into Form and page in your note. Use these digits as the form ID; the shortcode may display a different hash.
Create one Google Tag Manager trigger that matches the successful-send event and the chosen form ID.
In Google Tag Manager, open Variables. Under User-Defined Variables, select New and choose Data Layer Variable. Enter formid for Data Layer Variable Name, keep the default data-layer version, and name the variable DLV - formid. Save it.
In Triggers, create a Custom Event trigger. Enter gtm4wp.contactForm7MailSent as the Event name. Choose Some Custom Events, then add the condition DLV - formid equals the numeric form ID in your note. Save the trigger with a name that identifies the form, such as CF7 - successful send - [form name].
Before adding the tag, open existing Google Analytics: GA4 Event tags in this GTM container. Inspect each tag’s Event Name and Measurement ID for generate_lead sent to the G- stream in your note. In WordPress Plugins > Installed Plugins, check whether another form or Analytics plugin sends GA4 events. If another source may send this form’s generate_lead, ask the maintainer: “Which one source should send generate_lead for this form?” Keep one source so a successful send is not counted twice.
Create a Google Analytics: GA4 Event tag for the selected form's successful send.
G- Measurement ID from your note, set Event Name to generate_lead, and add the event parameter form_id. For its value, select the variable-picker icon and choose DLV - formid; do not type the variable name as plain text. Select the successful-send trigger you created, then save the tag.In Google Analytics, open Admin > Data display > Events. A key event is an action you choose to highlight as important in reports. This setting is for the generate_lead event name; the GTM trigger above still limits this tag to the selected form.
Under Recent events, find generate_lead. If its star is not on, click the star to mark it as a key event. In Key events, open the row’s Action menu > Change counting method, select Once per event, and save if the selection changed. Then open Action menu > Set default key event value and choose Don’t set a default key event value; save if the selection changed. If either choice is already selected, leave it as it is.
Only if generate_lead is not listed under Recent events, select + Create event, enter generate_lead, turn on Mark as key event, choose Once per event and Don’t set a default key event value, then choose Create with code and create it. This registers the event your GTM tag will send; do not create a page-view rule or a second event source.
Preview first so errors and successful sends are easy to tell apart. Publish only after the chosen form sends the GA4 event once for success and not for an unsuccessful attempt.
Use Tag Manager Preview with a test entry to check one unsuccessful attempt and one successful send.
In the GTM container workspace, select Preview, enter the form page address from your note, and connect Tag Assistant. On the connected form page, leave a required field empty and select Submit. In Tag Assistant, choose gtm4wp.contactForm7InvalidInput; confirm the generate_lead tag did not fire.
Submit one successful test using details you control. In Tag Assistant, choose gtm4wp.contactForm7MailSent; confirm DLV - formid matches your form ID and the GA4 Event tag fires once. If the following gtm4wp.contactForm7Submitted message appears, confirm the GA4 tag does not fire again.
In Google Tag Manager, review the workspace changes and select Submit. Choose Publish and Create Version, add a version name and short description for the Contact Form 7 lead event, review the change list, and publish the tested version.
After the tag is published and the key-event setting has applied, send a new successful test and check its Live receipt in Tag Assistant and GA4 Realtime.
If you just marked generate_lead, Google says the setting can take a few minutes to a few hours to apply. Check Admin > Data display > Events > Key events until generate_lead is on. Then use a new form submission for the receipt check; refreshing an earlier result does not send a new event.
In the connected Tag Assistant window, open the container details and select Change container environment or version. Choose Environment ID 1 / Live, then select its Debug link. When Tag Assistant says the container is updated for debugging, select Reload page. Before testing, confirm the details show Container Version Live for the GTM- ID in your note.
Submit the form successfully again using details you control. In Tag Assistant, confirm the GA4 Event tag fires once on gtm4wp.contactForm7MailSent. In Google Analytics, open Reports > Realtime and look for the new generate_lead under Event count by Event name. Open its details and confirm form_id matches your chosen numeric form ID. Check Key events by Event name for the fresh event.
Write the test date, the new generate_lead event, matching form_id, key-event state, and Live GTM version under Live check in your note. If Realtime receives the event but the key-event card has not updated, wait for Google's setting to apply, then send another new successful test. If the event is missing, ask the site maintainer to check the container, stream ID, and form trigger.