Setting Up Data Layer Event For Contact Form 7 Submissions
First, we will set up an event listener for contact form 7 successful submissions. This uses the existing event for contact form 7 submissions. You can find Contact Form ‘s DOM events here.
We use the event listener and fire the data layer events with a custom HTML tag that fires on all pages (where the contact form exists).
Code:
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
window.dataLayer.push({
"event" : "cf7submission",
"formId" : event.detail.contactFormId,
"response" : event.detail.inputs
})
});
</script>

Tag type: Custom HTML
Trigger: All pages (that the contact form exists on)
Explanation:
This tag fires a data layer event named “cf7submission” which can then be used as a trigger for other tags to use as a successful form submission.
Additionally, it passes 2 variable ids, “formId” and “response”.
The formId is a unique ID for the contact form. This can be useful if you have multiple contact forms and want to be able to track which form has been submitted or only track specific forms by filtering it on a trigger.
The response tracks the details of the inputted form fields. Please view the structure of the JSON for this in the data layer and select specific fields that you need to pass. Please be careful when using this that you comply with platforms terms and conditions and don’t pass PII (personally identifiable information) into platforms that don’t allow it e.g. Google Analytics.
Creating Data Layer Variables for Contact Form 7 Events
We can then create a data layer variable to access the form ID in Tag Manager.
Variable type: data layer variable
Data layer variable name: formId (exactly matching the ID in the custom HTML tag).
Using data layer version 2.

Tracking Contact Form 7 Events and Data to a Third Party (e.g. Google Analytics 4)
Using the data layer event and data layer variable created to create a trigger and pass dynamic information in a tag to a third party. We will go through an example of this using Google Analytcs 4.
Firstly, we can create a trigger to fire on the new data layer event
Trigger Configuration
Trigger type: custom event
Event name: cf7submission (exactly matching the event name in the custom HTML tag code)
Trigger fires on: all custom events

Next, we can put this all together with a Google Analytics 4 Event Tag.
This assumes you already have the Google Analytics 4 configuration tag set up.
GA4 Tag Configuration
Tag name: GA4 – Event – CF7 Submission
Tag type: Google Analytics: GA4 Event
Event name: form_submission
Event parameters:
form_id = {{DLV – Form ID}} – This distinguishes events received from different Contact Form 7 forms.
form_type = cf7 – This can be included if you use different form providers on your website to help categorise them in Google Analytics.
Trigger: CF7 – Contact Form Submitted (custom event)

As always, the event parameter names and values can be customised to your liking to fit in best with your Google Analytics set up.
Conclusion
After setting up your tags, variables and triggers, it’s always best to preview changes and test it is working as expected prior to publishing to the live website.
The data layer events, variables and triggers can also be used from here to build further tags to send information to other third parties.
Let me know if you have any questions in the comments or any other topics you would like covered next!
Hello team,
I’m writing through your contact form on purpose. If I were a customer, could you call me back in the next 5 minutes?
People who fill in a form usually contact other businesses too. The first one to call often gets the customer. With us, that’s you.
As soon as someone fills in a form on your website, we call them about 30 seconds later, and you pick who they talk to:
1. You or your staff. Your phone rings and we connect you while they’re still on your website. Busy or closed? Our AI takes the call.
2. Our AI, on every call. It answers their questions, qualifies them and books the appointment, day or night, then sends you the transcript.
Try it: go to https://ultraleadgeneration.com, click the blue phone icon in the bottom corner and enter your number. Your phone will ring. The demo is the AI option.
No credit card is needed on our Basic plan. A real person helps you get set up. The first 14 days are free.
Thanks,
Serena, Ultra Lead Generation
Not for you? Opt out here: https://ultraleadgeneration.com/unsubscribe.aspx?d=thedigitalmetric.com
Hello there,
You’re reading this because I just filled in your contact form. Picture I’m a new customer: how long until I hear back?
An MIT study found that calling a web lead within 5 minutes rather than 30 makes you 100 times more likely to connect with them. That’s the call we make for you.
As soon as someone fills in a form on your website, we call them in about 30 seconds, and you choose who answers:
1. You or your team. Your phone rings and we connect you while they’re still on your site. Busy or closed? Our AI picks up instead.
2. Our AI, on every call. It answers their questions, finds out what they need and books the appointment, 24/7, then sends you the transcript.
Try it: visit https://firstleadgen.com, click the blue phone icon in the bottom corner and type in your number. It calls you. You’ll hear the AI option.
A real person helps you get set up. No card is needed on our Basic plan. It’s free for 14 days.
Cheers,
Bryce, First Lead Gen
Not for you? Unsubscribe here: https://firstleadgen.com/unsubscribe.aspx?d=thedigitalmetric.com
Hello team,
A quick experiment: this note came through your contact form. If I were a real customer, the clock would already be running.
A Drift study of 433 companies found that only 7% answered a web form within 5 minutes. Most hadn’t replied 5 business days later. With us, you’d be in the 7%.
As soon as a customer requests a call on your site, we call them in about 30 seconds, and you choose who they talk to:
1. You or your staff. We ring your phone and connect you while they’re still on your website. Busy or closed? Our AI picks up instead.
2. Our AI voice agent. It answers their questions, qualifies them and books the appointment, 24/7, then sends you a full transcript.
Try it: visit https://firstleadgen.com, click the blue phone icon in the bottom corner and enter your number. We’ll call you. The demo shows the AI option.
No card is needed on our Basic plan. The first 14 days are free. A real person helps with setup.
Cheers,
Margarita, First Lead Gen
Not for you? Opt out here: https://firstleadgen.com/unsubscribe.aspx?d=thedigitalmetric.com