How to set up Contact Form 7 tracking

If your website uses Contact Form 7 and you are running ad campaigns, setting up Contact Form 7 conversion tracking for Google Ads and Facebook Ads is a must. This article will help you track Contact Form 7 events with Google Tag Manager and send them to Google Analytics 4 and your ad platforms. I will also show you how to track where Contact Form 7 conversions come from in Google Analytics, email, and Google Sheets.

Tracking Contact Form 7 events with Google Tag Manager

If you work in digital marketing, you are probably familiar with Google Tag Manager. If not, see how to use Google Tag Manager. In this article, I’ll go straight to tracking Contact Form 7 events and skip the Google Tag Manager basics.

Step 1: Create a new Tag of type Custom HTML and paste in the code below. Set the Trigger to All Pages. You can name the Tag whatever you like, for example, CF7 Create Event.

<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
    window.dataLayer.push({
    "event" : "cf7submit",
    })
}); 
</script>
Tracking Contact Form 7 events with Google Tag Manager
Tracking Contact Form 7 events with Google Tag Manager

Step 2: Create a new Trigger of type Custom Event and enter cf7submit as the Event name. Again, any Trigger name works, for example, CF7 Submit.

cf7submit
Create a Trigger for Contact Form 7 event tracking
Create a Trigger for Contact Form 7 event tracking

Now you have a Contact Form 7 event and Trigger in Google Tag Manager. If you want to send Contact Form 7 events to Analytics or set up Contact Form 7 conversions for Google Ads and Facebook Ads, read on.

Contact Form 7 events in Google Analytics 4

First of all, make sure you have added Google Analytics to your website. Google stopped processing Universal Analytics data on July 1, 2023, so I have removed the old Universal Analytics tag instructions from this article; you only need to set this up for GA4 now.

Create a new Tag of type Google Analytics: GA4 Event, select CF7 Submit as the Trigger, then fill in the following:

  • Measurement ID: your GA4 ID, which looks like G-XXXXXXXXXX.
  • Event Name: generate_lead. This is the event name Google recommends when a visitor leaves their contact details. You can use another name such as cf7_submit, as long as it only contains letters, numbers and underscores, with no spaces.

Note: You don’t need to add {{Page Path}} like the old Universal Analytics tag, because GA4 records the page URL with every event automatically. The current GA4 Event tag also no longer has a Configuration Tag field, but you should still have a Google Tag with the same ID firing on All Pages (or GA4 installed directly on the site) so the event is tied to the right session.


After saving the Tag, remember to publish the container so the Tag goes live. To check Contact Form 7 events in GA4, go to Reports > Realtime, submit a test form, and look for generate_lead in the Event count by Event name card.

If you want to use this event as a conversion in GA4, go to Admin > Data display > Events and click the star icon to mark generate_lead as a key event. New events can take up to about a day to appear in this list, so give it some time if it isn’t there yet.

Contact Form 7 conversion in Google Ads

This method doesn’t require linking your Google Ads account to Google Analytics. That’s very convenient if you are an agency and it isn’t practical to ask clients for Google Analytics permission.

Step 1: In your Google Ads account, go to Goals > Conversions > Summary. The screenshot below shows the old interface, when this menu was under Tools and Settings > Conversions.

Go to conversion management in Google Ads
Go to conversion management in Google Ads (old interface)

Step 2: Create a new website conversion action.

Create a website conversion to track Contact Form 7 in Google Ads
Create a website conversion to track Contact Form 7 in Google Ads

Step 3: Fill in the details, and at the tag setup step, select Use Google Tag Manager. Copy the Conversion ID and Conversion label for the next step.

Copy Conversion ID and Conversion Label to track Contact Form 7 in Google Ads
Copy Conversion ID and Conversion Label to track Contact Form 7 in Google Ads

Step 4: Go back to Google Tag Manager and create a new Tag of type Google Ads Conversion Tracking. Enter the Conversion ID and Conversion label you copied, select CF7 Submit as the Trigger, then save and publish. If your container doesn’t have a Conversion Linker tag yet, add one firing on All Pages, because the Google Ads conversion tag relies on it to measure ad clicks more accurately.

Create a Google Ads tag to track Contact Form 7 conversions
Create a Google Ads tag to track Contact Form 7 conversions

To check whether your Contact Form 7 conversion is set up correctly, click Preview in Google Tag Manager. Tag Assistant will open your website in debug mode; submit a test form, then go back to the Tag Assistant window to see the results. The Tag Assistant Legacy extension that this article used to recommend has been discontinued by Google, so there’s no need to install it. If you’re not sure how this works, see how to check if Google Tag Manager is working.

If the Google Ads Conversion Tracking tag (and the GA4 Event tag, if you added one) appears under Tags Fired for the cf7submit event, your Contact Form 7 conversion is set up correctly.

Note that Google Ads records conversions a few hours later, so you won’t see Contact Form 7 conversions in your ad reports right away.

Contact Form 7 conversions in Facebook Ads

Before setting up Contact Form 7 conversions for Facebook Ads, make sure you know where to find your Facebook Pixel code. It is in the Event Sources section of Events Manager.

Step 1: If you haven’t added the Facebook Pixel to your website yet, create a Custom HTML Tag, paste in your Pixel code, and select All Pages as the Trigger.

Add the Pixel to your website before setting up Contact Form 7 conversions for Facebook Ads
Add the Pixel to your website before setting up Contact Form 7 conversions for Facebook Ads

Step 2: Create another Custom HTML Tag and select CF7 Submit as the Trigger. Pick the event type that fits best from the table below and paste its code into the Tag. You can find other event types on Facebook’s information page.

Action eventEvent code
Complete registration<script>fbq(‘track’, ‘CompleteRegistration’);</script>
Contact<script>fbq(‘track’, ‘Contact’);</script>
Donate<script>fbq(‘track’, ‘Donate’);</script>
Lead<script>fbq(‘track’, ‘Lead’);</script>
Purchase<script>fbq(‘track’, ‘Purchase’, {value: 0.00, currency: ‘USD’});</script>
Schedule<script>fbq(‘track’, ‘Schedule’);</script>
Submit application<script>fbq(‘track’, ‘SubmitApplication’);</script>

In this article, I chose Submit Application (SubmitApplication), so the Tag looks like this. Then save and publish so the Tag goes live.

Create a Contact Form 7 tracking tag for Facebook Ads
Create a Contact Form 7 tracking tag for Facebook Ads

To check that your Contact Form 7 tracking for Facebook Ads works, install the Facebook Pixel Helper extension in Chrome.

If Pixel Helper records the event after you submit the form, your Contact Form 7 tracking for Facebook is working.

Check Contact Form 7 conversions with Facebook Pixel Helper
Check Contact Form 7 conversions with Facebook Pixel Helper

You can also check Contact Form 7 conversions directly in Events Manager. Once you see the event recorded, you can create a new campaign with a conversion objective.

Check Contact Form 7 events in Facebook Events Manager
Check Contact Form 7 events in Facebook Events Manager

Besides Google Ads and Facebook Ads, you can track Contact Form 7 conversions for other ad networks too. The Trigger stays the same; only the Tag changes depending on the network. See MGID conversion tracking for an example.

Contact Form 7 source tracking

I have received several requests for help tracking where Contact Form 7 conversions come from, especially from those of you using Contact Form 7 connected to Google Sheets. So here is a step-by-step guide.

Contact Form 7 source in Google Analytics using UTM

Google Analytics records traffic sources automatically, so by default you don’t need to do anything. But if you want Google Analytics to attribute Contact Form 7 conversions to specific ad campaigns more precisely, use Google UTM.

  • Website URL: paste the URL you use in your ads.
  • Campaign source: the ad channel, such as Facebook, Google, Instagram…
  • Campaign medium: the ad format, such as Banner, Click, CPC, Conversion…
  • Campaign name: the campaign name, such as BlackFriday, FlashSale…

Use the generated link in your ad campaigns, and Google Analytics will attribute your Contact Form 7 conversions according to your UTM parameters.

Attach Google UTM to Contact Form 7
Attach Google UTM to Contact Form 7

Contact Form 7 source in email

If you want the notification emails to include the conversion source, install the HandL UTM Grabber plugin and follow the steps below.

Requirements: Your ads use UTM links, and the HandL UTM Grabber plugin is installed. The plugin version I tested successfully for this guide is 2.7.19. If the latest version doesn’t work for you, try this one.

Step 1: In WordPress, go to Contact > Contact Forms, edit your form, and paste the code below just before the submit button.

<p style="display:none">
<label style="display:none">[date date-sent hidden "today"]</label>
[utm_source_i]<label style="display:none">[text utm-source "%s"]</label>[/utm_source_i]
[utm_medium_i]<label style="display:none">[text utm-medium "%s"]</label>[/utm_medium_i]
[utm_campaign_i]<label style="display:none">[text utm-campaign "%s"]</label>[/utm_campaign_i]
[utm_term_i]<label style="display:none">[text utm-term "%s"]</label>[/utm_term_i]
[utm_content_i]<label style="display:none">[text utm-content "%s"]</label>[/utm_content_i]
</p>
Add the code to send UTM for Contact Form 7
Add the code to send UTM for Contact Form 7

Step 2: Switch to the Mail tab and paste the code below into the message body. It includes the UTM values plus the page URL, date, and time of submission. Pretty thoughtful, right? 😀

URL: [_url]
Date: [date-sent]
Time: [_time]

Campaign Source: [utm-source]
Campaign Medium: [utm-medium]
Campaign Name: [utm-campaign]
Campaign Term: [utm-term]
Campaign Content: [utm-content]
Add the code to send Contact Form 7 source UTM in the email
Add the code to send Contact Form 7 source UTM in the email

And here is what the notification email looks like.

Contact Form 7 email notification results with UTM source
Contact Form 7 email notification results with UTM source

Contact Form 7 source in Google Sheets

If you are sending data from Contact Form 7 to Google Sheets and want to include the UTM values, follow this tip. Complete step 1 of the previous section first, then continue below.

Requirements: Your ads use UTM links, and you have done step 1 of the email section above. The CF7 Google Sheets Connector version I tested successfully for this guide is 4.7. If a newer version gives you trouble, try reinstalling this one.

Add these column names to your sheet, even though CF7 Google Sheets Connector doesn’t show these fields in the form settings.

date-sentutm-sourceutm-mediumutm-campaignutm-termutm-content
Send Contact Form 7 UTM source data to Google Sheets
Send Contact Form 7 UTM source data to Google Sheets

Conclusion

I hope this article helps marketers running ads for websites that use Contact Form 7. If you have any questions or run into problems, feel free to leave a comment below.

Hieu Tran Ngoc Minh

Hieu (born in 1996) holds a Bachelor's degree in Business Administration from Saigon Technology University. Currently a Data Analyst at Ninja Van, Hieu has extensive experience in Data Analysis and Digital Marketing. This blog is where Hieu shares practical experiences from work and life.

2 Comments

  1. Is the Step 1 (adding the Event listener) to the site necessary for setting the Google Ads Conversions? Whatever I do there is an “Inactive” badge next to my conversion goal.

    Reply

Leave a Comment

Feel free to leave your comment (preferably in English), and we will review and respond as soon as possible. Please use a real email to ensure your comment is approved and to receive notifications when we reply. You can also add an avatar to your email.