Contact Form 7 (CF7) Submissions Tracking Using Google Tag Manager

Tracking form submissions in Contact Form 7 (CF7) is crucial for measuring conversions and user interactions. In this guide, I’ll show you how to track CF7 submissions using Google Tag Manager (GTM) with a simple data layer implementation.


Step 1: Create a CF7 Listener Tag

We start by capturing the CF7 submission event using a custom HTML tag.

  • Go to Tags in GTM
  • Click New
  • Name it: CF7 – Listener
  • Select Custom HTML

Paste the following code:

<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
 window.dataLayer.push({
 "event" : "cf7submission",
 "formId" : event.detail.contactFormId,
 "response" : event.detail.inputs
 })
}); 
</script>
  • Set the trigger to All Pages

This script listens for successful form submissions and pushes relevant data into the data layer.


Step 2: Create a Custom Event Trigger

Next, configure a trigger to capture the data layer event.

  • Go to Triggers
  • Click New
  • Name it: Custom – cf7submission
  • Select Custom Event
  • Event Name: cf7submission

This trigger will fire whenever a CF7 form is submitted successfully.

Optional: Track Multiple Forms Separately

If you want to track different forms individually:

  • Add a condition in the trigger
  • Set: Form ID Variable equals [Specific Form ID]

This allows you to create unique tracking for multiple forms.


Step 3: Create a Data Layer Variable

Now, extract the form ID from the data layer.

  • Go to Variables
  • Click New
  • Name it: dlv – formId
  • Variable Type: Data Layer Variable
  • Data Layer Variable Name: formId

This variable captures the unique ID of each submitted form.


Step 4: Create the Final Tracking Tag

Finally, send the captured data to your analytics tool (such as GA4).

  • Go to Tags
  • Click New
  • Name it: Contact Form Submission

Configuration:

  • Event Name: Contact Form Submission
  • Parameter Name: form_id (optional)
  • Parameter Value: {{dlv – formId}}
  • Trigger: Custom – cf7submission

This setup ensures all CF7 submissions are properly tracked and available for reporting.


Conclusion

With this implementation, you can:

  • Track all Contact Form 7 submissions reliably
  • Capture form IDs for granular analysis
  • Differentiate between multiple forms if needed

This method is lightweight, flexible, and does not require modifying your existing CF7 forms.


Tip: Use GTM Preview mode to test your setup before publishing to ensure everything fires correctly.