If you’re running Google Ads, tracking form submissions is the “holy grail” of data. While Contact Form 7 (CF7) is the most popular WordPress form plugin, it doesn’t play nicely with Google Tag Manager (GTM) out of the box because it doesn’t trigger a page reload.
In this guide, we’ll show you how to use a simple JavaScript snippet to capture CF7 data and send it to Google Ads via GTM.
Why Use This Method?
Standard tracking often relies on “Thank You” pages. However, modern UX prefers AJAX submissions (where the form sends without refreshing). The script below listens for the specific CF7 event (wpcf7submit) and pushes that data into the dataLayer.
Step 1: Add the Custom Script to Your Site
First, we need your website to “talk” to GTM when a form is sent. Paste the following code into your website’s footer (or via a “Custom HTML” tag in GTM set to fire on All Pages).
HTML
<script>
(function() {
document.addEventListener( 'wpcf7submit', function( event ) {
var inputs = event.detail.inputs;
var data = {};
for (var i = 0; i < inputs.length; i++) {
data[inputs[i].name] = inputs[i].value;
}
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'cf7submission',
'formId': event.detail.contactFormId,
'formData': data
});
}, false );
})();
</script>
What this script does:
- Listens for the successful submission of any CF7 form.
- Gathers the input values (like name or email).
- Pushes a custom event named
cf7submissionto GTM.
Step 2: Create a Custom Event Trigger in GTM
Now that the data is being sent, GTM needs to know to look for it.
- Log in to Google Tag Manager.
- Go to Triggers > New.
- Choose Trigger Type: Custom Event.
- Event Name:
cf7submission(It must match the script exactly). - Set it to fire on All Custom Events and click Save.
Step 3: Set Up Your Google Ads Conversion Tag
Now, let’s link that trigger to your Google Ads account.
- Go to Tags > New.
- Choose Tag Configuration > Google Ads Conversion Tracking.
- Enter your Conversion ID and Conversion Label (found in your Google Ads account under Conversions).
- In the Triggering section, select the
cf7submissiontrigger you created in Step 2. - Save and Publish.
Step 4: Verification (The Most Important Step)
Before you celebrate, ensure everything is working:
- Open GTM Preview Mode and enter your website URL.
- Fill out your Contact Form 7 on your site and click submit.
- In the GTM Debug window, look for the
cf7submissionevent in the left-hand sidebar. - Click the event and verify that your Google Ads Conversion Tag fired successfully.
Summary Table: Key Elements
| Element | Value |
| GTM Event Name | cf7submission |
| Trigger Type | Custom Event |
| Data Captured | Form ID and Input Data |
| Compatibility | All CF7 forms using AJAX |
Pro Tip:
If you have multiple forms and only want to track one as a conversion, you can use the formId variable pushed by the script to create a trigger that only fires when formId equals your specific ID.
