Contact Form 7 + GA4 Conversion Tracking Setup
I see broken Contact Form 7 → GA4 tracking in about 35% of WordPress sites I audit. The most common issue? People assume CF7 automatically sends conversion data to GA4, but CF7 only fires a DOM event that most setups completely miss. Without proper event listeners, you’re flying blind on your lead generation performance.
What You’ll Have Working By The End
- Contact Form 7 submissions automatically tracked as GA4 conversion events
- Proper event data including form ID and submission timestamp
- GA4 conversion goals marked and counting in real-time
- Cross-verification system to ensure accurate tracking
- Troubleshooting skills for the most common CF7 + GA4 issues
Prerequisites
- Contact Form 7 plugin installed and active on WordPress
- GA4 property set up with measurement ID
- Google Tag Manager container installed on your WordPress site
- GTM Editor access (not just View access)
- GA4 Admin access to mark events as conversions
Step 1: Set Up the Contact Form 7 Event Listener
Contact Form 7 fires a wpcf7mailsent DOM event when forms submit successfully. You need to catch this event and push it to the data layer.
Add this code to your WordPress theme’s footer.php (or better yet, enqueue it properly):
document.addEventListener('wpcf7mailsent', function(event) {
// Get form details
var formId = event.detail.contactFormId;
var formTitle = event.detail.inputs.find(input => input.name === 'your-subject')?.value || 'Contact Form ' + formId;
// Push to data layer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'cf7_form_submit',
'form_id': formId,
'form_name': formTitle,
'timestamp': Date.now()
});
console.log('CF7 submission tracked:', formId);
});
Important: This listener only fires on successful submissions. If CF7’s email sending fails, this event won’t fire — which is actually what you want for conversion tracking.
Step 2: Create the GTM Trigger
In Google Tag Manager:
- Go to Triggers → New
- Trigger Configuration: Custom Event
- Event name:
cf7_form_submit(matches your data layer push) - This trigger fires on: All Custom Events
- Name: “CF7 Form Submission”
- Save
For more specific tracking, you can filter by form ID:
- This trigger fires on: Some Custom Events
- Fire this trigger when: Form ID equals [your specific form ID]
Step 3: Configure the GA4 Event Tag
Create the GA4 event tag:
-
Go to Tags → New
-
Tag Configuration: GA4 Event
-
Measurement ID: Your GA4 measurement ID
-
Event Name:
generate_lead(recommended event) orcf7_submission(custom) -
Event Parameters:
- form_id:
{{DLV - form_id}}(create this data layer variable first) - form_name:
{{DLV - form_name}} - page_location:
{{Page URL}} - value: 1 (optional, for conversion value)
- form_id:
-
Triggering: Select your “CF7 Form Submission” trigger
-
Name: “GA4 - CF7 Lead Generation”
-
Save
Which event name should you use? Use generate_lead if you want to leverage GA4’s enhanced ecommerce reporting. Use a custom event name like cf7_submission if you want more control over the naming.
Step 4: Create Required Data Layer Variables
You need these GTM variables to capture the form data:
Variable 1 - Form ID:
- Variables → New
- Variable Configuration: Data Layer Variable
- Data Layer Variable Name:
form_id - Name: “DLV - form_id”
Variable 2 - Form Name:
- Variable Configuration: Data Layer Variable
- Data Layer Variable Name:
form_name - Name: “DLV - form_name”
Step 5: Set Up Client-Side GTM Configuration
For Client-Side GTM implementation, add this enhanced tracking script:
// Enhanced CF7 tracking with additional data
document.addEventListener('wpcf7mailsent', function(event) {
var detail = event.detail;
var formElement = event.target;
// Extract form data
var formData = {
'event': 'cf7_form_submit',
'form_id': detail.contactFormId,
'form_title': formElement.getAttribute('data-title') || 'Contact Form ' + detail.contactFormId,
'form_url': window.location.href,
'user_agent': navigator.userAgent,
'timestamp': new Date().toISOString(),
'submission_id': detail.into.replace('#', '') // CF7 generates unique IDs
};
// Add any additional custom fields you want to track
var emailField = formElement.querySelector('input[type="email"]');
if (emailField && emailField.value) {
formData.email_domain = emailField.value.split('@')[1];
}
// Push to data layer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push(formData);
// Debug logging
console.log('CF7 Enhanced Tracking:', formData);
});
This gives you richer data for analysis and troubleshooting.
Step 6: Mark as Conversion in GA4
Once your events start flowing:
- GA4 → Events (under Reports)
- Find your event (
generate_leadorcf7_submission) - Click the toggle under Mark as conversion
- Wait 15-30 minutes for the conversion to appear in reporting
The conversion will now show up in:
- GA4 Conversions report
- Google Ads (if linked)
- Attribution reports
Testing & Verification
Real-time Testing:
- Submit a test form on your site
- GA4 → Reports → Realtime
- Check Events in the last 30 minutes for your event
- Verify event parameters are populated correctly
Debug View Testing:
- Install GA4 DebugView Chrome extension
- GA4 → Admin → DebugView
- Submit a test form
- Event should appear within 10-20 seconds with all parameters
GTM Preview Mode:
- GTM → Preview
- Load your site with the preview bar active
- Submit form → check if trigger fires and tag sends
- Look for “Tags Fired” showing your GA4 event tag
Cross-Verification: Contact Form 7 doesn’t store submissions by default, so install Flamingo plugin for comparison:
- Flamingo submissions count should match GA4 conversion count within 5-15%
- Higher variance usually indicates tracking issues or bot submissions
Troubleshooting
Problem: Event listener not firing at all
Check that Contact Form 7 is actually sending emails successfully. CF7 only fires wpcf7mailsent after successful email sending. Test with a working email configuration first.
Problem: GTM trigger not firing despite data layer push Use GTM Preview mode and check the data layer tab. If the event appears there but trigger doesn’t fire, your trigger configuration is wrong. Most commonly, the event name doesn’t match exactly.
Problem: GA4 receiving events but not showing as conversions You forgot to mark the event as a conversion in GA4. Go to Events report, find your event, and toggle “Mark as conversion”. It takes 15-30 minutes to start showing conversion data.
Problem: Duplicate events on single form submission
You have multiple event listeners or CF7 is submitting via AJAX and regular form submission. Add event.preventDefault() and ensure you only have one listener per form.
Problem: Events firing but missing form_id parameter
CF7’s contactFormId is only available in the event detail after successful submission. If you’re seeing undefined, the form isn’t completing its submission process properly.
Problem: Conversion count way higher than actual submissions
You’re likely tracking page views or other events as conversions. Check your GTM trigger conditions — it should only fire on cf7_form_submit custom events, not all events.
What To Do Next
- Contact Form 7 Google Ads Conversion Tracking — Send these same conversions to Google Ads
- Contact Form 7 Meta Ads Conversion Tracking — Track CF7 submissions in Meta’s Conversions API
- Contact Form 7 to HubSpot Integration — Push form data directly into your CRM
- Get a free tracking audit — I’ll check your CF7 + GA4 setup and identify any issues
This guide is part of the GA4 Conversion Tracking Hub — complete guides for tracking conversions from any form or landing page into GA4.