During 2018 a lot of users had problems with goals in Google Analytics. 95% of those case were connected with 2 things:

  • After the release of the version 5+ of Contact Form 7 the old way of creating goals (on_sent_ok) didn’t work and the developers suggested using DOM-events.
  • Since the end of 2017 all the new accounts on Google Analytics were suggested to set a new tracking code: Global Site Tag, or gtag.js.

This article is going to tell you, how to create and edit goals in Contact Form 7 in 2020, so that they work. We use the real web-site Mebelzakaz5.by as the example. At the end of the article you can find the information on how to check the efficiency of your goals.

DOM-events of Contact Form  7 – what and for what is it

Till the version 5 of Contact Form 7 we used to use on_submit or on_sent_ok settings to track the goal. And used to type it in the “Additional Settings” tab:

But since the 5.0 version of CF7 those settings were replaced by DOM-events. The developers explained that by the security threat, which can be caused by on_submit or on_sent_ok settings, moreover, they were outdated.

Here are some available DOM-events:

wpcf7invalid – works, when some fields are filled in incorrectly, the form is not sent;

wpcf7spam – works, when spam is suspected, the form is not sent;

wpcf7mailsent – works, when the form is filled in successfully and the email is sent;

wpcf7mailfailed – works, when the form is filled in successfully, but the email is not sent because of some error;

wpcf7submit – works, when the form is successfully sent, regardless of the other accidents

Today we’re going to use wpcf7mailsent, which works when the form is sent.

How to create goals in Google Analytics for Contact Form 7

It’s not so easy, because of the confusion between the old and the new tracking code.

The old tracking code of GA – analytics.js (until 2018):

The new tracking code of GA – gtag.js (since 2018):

It must be admitted, that both the new and the old codes work fine and transmit data to Analytics. So if your site has the old code, don’t worry. But if you want to learn the difference, read it below.

What’s the difference between the old and the new codes?

The only aim of the new counter is to have a centralized tag , which transmit data to all the marketing and analytical Google tools.  

More details on habr.com

How to edit goals in Google Analytics

1. Choose the site, go to Admin

2. Find the View tab and choose Goals

3. Click on +New Goal

4. a) In Goal setup you choose Custom;

b) In Goal description you type the name of the goal and choose Event as the type of it;

c) In Goal details you type unique ID in Category, then you type “Submit” in Action;

d) In Use the Event value as the Goal Value for the conversion choose Yes

Setting the tracking of the goal on WordPress

Before you edit the goals, you need to know which tracking code your site has. The easiest way to do it is to press “Ctrl+U” and find the counter code.

If you’ve got the old counter, your tracking code is the following:

If you’ve got the new counter, your tracking code is the following:

Instead of “formapopup” you type your ID, which you pointed in the Category field. “Submit” – is what you typed in the Action field.

How to create goals in definite or several forms of Contact Form 7

The paragraphs above told you about the tracking method that works when any CF7 form is sent on your site. Now you’re going to learn how to set the tracking of the definite form being sent. 

The developers suggest using event.detail.contactFormId feature. There are other methods, but this one is the easiest.

In order to make such a form, you need to know it’s ID. Go to Contact form 7 and in column Shortcodes you can see its ID.

Click on the image to enlarge it

So you’ ve got the ID of your form. Now you substitute your ID instead of mine (1753) in this code:

Now the information about the sending of the form is conveyed to Google Analytics.

As you’ve already guessed, you need to paste this code to the Footer or the Header of your site. In the line ‘event_category’ instead of ‘formapopup’ you type the category that you selected when you setted the goal details on Google Analytics.

Example of a tracking code for goals from several forms:

How to check whether goals work in Google Analytics

There are several methods, so let’s  consider them:

1. Universal method

Add to the code of the goal the following:

Instead of “works” you can type anything you want.

As the result, it looks like this:

Go to the site and send the form. Bring up the console with the shortcut Ctrl+Shift+I (for Chrome and Opera) or click on the right mouse button and choose Inspect. Then go to the Console tab and check if the goal worked.

Click on the image to enlarge it

2. Fast check

Go to Google Analytics site, find Realtime, then Events. There you can see all the events, that happened during the last 30 minutes.

Click on the image to enlarge it

How to create and edit goals in Google Analytics for Contact Form 7

In Conversions tab you can see the goals that were achieved during the last 30 minutes.

Click on the image to enlarge it

How to create and edit goals in Google Analytics for Contact Form 7

That’s all! Now you know enough to create and edit goals for Contact form 7 in 2020. Any questions? Ask them in the comments!

Have you not understood? We can help you! Read the information below.

We set up to 10 goals for just $10 for you

For $10 only we can cet 10 goals for any events (not only CF7) on a wordpress site.

Write us on agencyagvento@gmail.com, on Telegram or leave a request below:

    5 1 vote
    Article rating
    Notify of

    Newest Most Voted
    Inline Feedbacks
    View all comments
    Lonken Hong
    2 years ago

    Very useful article, I don’t like to use plugins to implement this function. The more plugins, the more delay the website will be. Thank you!

    MK ROY
    MK ROY
    2 years ago

    First time I planed to install plugin. But after this tutorial, I implement Goal feature manually. Though took some time to get the results. Here is my website (fotomasking.com) and added it onto the contact form submit button/even 🙂

    Thank you so much.

    Would love your thoughts, please comment.x