How to Setup Contact Form 7 Event Tracking with Google Tag Manager

Sumit Kumar
7 Min Read

Contact Form 7 is one of the most popular plugins for WordPress & the best part of this plugin is – it can easily be tracked in Google Analytics through Google Tag Manager. The best part of this plugin is you don’t need to create a thank you page for this & Google Analytics has no issues with it.

To set up the tracking, we would be required to:

  1. Contact Form 7 plugin installed on your WordPress
  2. Google Analytics Installed on your WordPress
  3. Google Tag Manager installed on your WordPress

STEP 1: Create a GTM tag for the Form Submission Event

Contact Form 7 Form Event submission means when you hit the form “Submit” button, an event fires which actually shows that your form has been submitted & the mail has been sent.

When someone submits the form, the Contact Form 7 plugin fires the DOM Events for several events which determine if the form has been submitted successfully or not. These DOM Events are:

  1. wpcf7invalid — Fires when form submission has been completed successfully, but mail hasn’t been sent because there are fields with invalid input.
  2. wpcf7spam — Fires when form submission has been completed successfully, but mail hasn’t been sent because a possible spam activity has been detected.
  3. wpcf7mailsent — Fires when form submission has been completed successfully, and mail has been sent.
  4. wpcf7mailfailed — Fires when form submission has been completed successfully, but it has failed in sending mail.
  5. wpcf7submit — Fires when form submission has been completed successfully, regardless of other incidents.

Since the wpcf7mailsent is that DOM Event which fires on form submission & mail sent successfully. We will create tags & triggers for this.

To create this tag:

  1. Go to Google Tag manager
  2. Click Tags on the left menu bar
  3. Click New on the dashboard
  4. Name this tag wpcf7mailsent, or what you feel is convenient.
  5. Click on Tag Configuration & Choose Custom HTML

Now, add the following code:

document.addEventListener( 'wpcf7mailsent', function( event ) {
          'event' : 'wpcf7successfulsubmit',
          'CF7formID' : event.detail.contactFormId
    	}, false );
  • Fire this tag to the All Pages –Page View  trigger
  • Save this tag
contact form 7 tutorial

STEP 2: Create a GTM Trigger for Above Tag

  1. Go to Google Tag manager
  2. Click Triggers on the left menu bar
  3. Click on New &name it as per your convenience (I have used  the name: Contact Form 7 Trigger)
  4. Click on Trigger Configuration & choose Custom Event
  5. Add event name wpcf7successfulsubmit
  6. Fire this trigger on All Custom Events
  7. Save this trigger
contact form 7 tracking google analytics

STEP 3: Create a Tag for Form Submission

  1. Go to Google Tag manager
  2. Click Tags on the left menu bar
  3. Click New on the dashboard
  4. Name this tag Contact Form Submission, or what you feel convenient
  5. Click on Tag Configuration & Choose Google Analytics: GA4 Event.
  6. Add the Event Name: Content_Form_Submission (This name will be used in Google Analytics 4 as a parameter)
    1. Action successful-form-submission-mailsent
    2. Label Enter Form ID, as mentioned in the Next step: 4.
    3. Non-Interaction Hit, choose the default value False
    4. Google Analytics Settings, choose you Google Analytics Settings
  7. Now, fire this tag on Contact Form 7 Triggerwhich we created in the previous step
content form 7 wordpress

STEP 4: Setting up the Conversion in Google Analytics 4

Now as the final step, you need to set a conversions for you successful form submission in Google Analytics 4.

To create the conversions, follow the below steps:

  1. Login to your Google Analytics account
  2. Navigate to Admin > View > Conversions. Click +New Conversion Event.
contact form 7 database
  • once you create it, don’t forget to test it multiple times using Google Tag Manager & Google ANalytics 7 debug mode.

So, this is the procedure which you need to follow when you create a conversion for Contact Form 7 through in Google Analytics 4 using Google Tag Manager.

Hope this you find this blog helpful. If you are having any issues while setting up conversion with the above procedure, just comment below & we will help you out.

If you need any assistance in your SEO campaign, you can hire us.

Need any help or assistance on Google Analytics 4?

Contact Form 7 Conversion Tracking FAQs

How to setup Contact Form 7 in Google Analytics 4?

If you have Contact Form 7 in Google Analytics plugin installed on your WordPress then you need to set up tags triggers using Google tag manager. This is a simple process.

How do I track a submission in Google Analytics 4?

Contact form 7 configuration in analytics required to google analytics event tracking which is done using Google Tag manager data layers. Once you are done with contact form 7 setup on WordPress, follow the steps mentioned in this blog to track Contact Form 7 submission.

What is the Contact Form 7 Plugin?

Contact Form 7 Plugin is a free WordPress plugin to create forms with simple HTML markup.

How to use Contact Form 7?

To use Contact Form 7, you need to install it to your WordPress & start creating forms. You can simply put the forms on any page using shortcodes.

Related Articles

How to Setup Google Ads Conversion Tracking in BigCommerce (With Order Amount & Order ID)

How to Setup Enhanced Ecommerce Tracking to WooCommerce

How to Setup Ninja Forms Event Tracking with Google Tag Manager

The Use of Artificial Intelligence (AI) in SEO – All You Need To Know

Best Website Traffic Monitoring Tools

How To Create Custom Reports In Google Analytics 4

Share This Article
  • This really helped me to setup form tracking for my website. I was struggling with that for a while. Thanks Sumit.

  • Hi Sumit, thank you very helpful.

    If we have several forms and want to track all uniquely, how would we adapt the triggers, tags or variables to find and fire only for specific form IDs? For example, we tried to update the trigger to “some custom events” and added “C7-formID contains [specific ID]” but am not getting the event to fire. Thoughts?

  • Hi,

    Thanks for the guidance,

    I was wondering how to do I get the form ID (here is 136), I stuck over there, while other points I followed.

    please help me for the same.


    I want that anywhere a contact form 7 will be submitted in a website, want to get it in Analytics. Do not want to create multiple events in Analytics.

    • Hi Flora,

      Thanks for writing to us.

      In the case of tracking multiple forms, you can create page specific triggers for the pages where the forms are added.

      If you still feeling any issues, please email me at I’d love to help you further.


  • Configure form tracking options and view reports within your WordPress dashboard way more convenient than using Google Analytics platform by itself.

  • Hello,
    Thank you for this great tutorial.
    I do have a question though, is there a way to replace the ID by the name of the form in GA? Instead of having 136 in your case, I would want to have Contact.
    I do have several forms and I find it easier to read if it shows the name of the form.

    • Hi Eve,

      We cannot change the IDs in forms as it is a third-party plugin, but when we create the tags, we can name them as per our convenience & setup Goals in Google analytics accordingly.

      Hope this help, let me know in case of further query & any help. feel free to email us at


  • hi!, I like your writing so a lot! share we keep in touch extra approximately your article on AOL? I require an expert in this area to resolve my problem. Maybe that is you! Taking a look ahead to peer you.

  • Its like you read my mind! You seem to know so much about this, like you wrote the book in it or something.

Leave a Reply

Your email address will not be published. Required fields are marked *