Tracking Submissions in GTM and GA4: Contact Form 7 and the Formless Approach

Оновлено 10.11.2026 · 4 хв читання

There are hundreds of guides online on «how to track Contact Form 7 in GTM,» but most were written for Universal Analytics, which is no longer available. This article covers the current setup for GA4, common mistakes in older guides, and the approach we at Liberty use on our own websites: Applications without forms or plugins.

What Is Outdated in the Old Instructions

  • Universal Analytics no longer works. Google stopped processing UA data in July 2023 and subsequently deleted the resources themselves. Tags such as «Google Universal Analytics» in GTM do not send any data.
  • «There are no more »goals.”. In GA4, goals are replaced by key events. You can mark any event as a key event with a single click.
  • Do not provide your email address or phone number to the analyst. Tips such as «pass the email field as an event label» violate Google Analytics’ rules regarding personal data and may result in the deletion of the site’s data.
  • Event on_sent_ok and the settings in the «Advanced Options» section of the form These features were removed from Contact Form 7 a long time ago. Only DOM events work.

How to Track Contact Form 7 in GTM and GA4 Today

Contact Form 7 submits the form via AJAX, without reloading the page, so the built-in GTM «Form Submission» trigger is unreliable here. The correct approach is to listen for the event wpcf7mailsent, which the plugin generates after the email is successfully sent.

Step 1. Listener Tag

In GTM, create a tag «User-Defined HTML» with a trigger All Pages (or only pages with a form):

<script>
document.addEventListener('wpcf7mailsent', function (event) {
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'cf7_sent',
    form_id: event.detail.contactFormId
  });
});
</script>

Please note: We only pass the form ID, not the field contents.

Step 2. Trigger and Variable

  • Trigger: «User Event», event name cf7_sent.
  • Variable: «Data Level Variable» titled form_id, to distinguish between forms if there are several on the website.

Step 3. GA4 Tag

Create a tag «Google Analytics: GA4 Event»:

  • Event Name: generate_lead (Google's recommended event for applications).
  • Event parameter: form_id = the variable from step 2.
  • Trigger: cf7_sent.

Step 4. Key Event and Verification

Turn on the mode «Preview» In GTM, send a test request and make sure the tag fired. Then, in GA4, open Administrator → Events and mark generate_lead as a key event. Now it can be imported into Google Ads as a conversion.

Why We Stopped Using Contact Form 7 and Forms in General

The setting above works, but it only treats the symptom. Over the years of supporting client websites, we've seen the same issues with forms on plugins:

  • Spam. Without reCAPTCHA and anti-spam plugins, the form collects hundreds of fake submissions, and each such plugin is yet another dependency.
  • Instability. Updating a plugin, theme, or WordPress breaks the submission or tracking, and they only find out about it when requests haven't been coming in for a week.
  • Letters get lost. Emails sent from a website without SMTP configured often end up in spam, and requests sitting in the inbox go unnoticed for hours.
  • Excess weight. The plugin's scripts and styles are loaded on pages that don't have forms, which slows down the site.
  • Slow response. The customer filled out the form and is waiting for a call, but in the meantime is reaching out to competitors.

Our approach: messaging apps, phone calls, and chat instead of a form

There are no forms on the websites we're currently building or on liberty.ua. Instead, with a single click, the customer can start a conversation wherever it's convenient for them:

  • Telegram and WhatsApp — link t.me/… і wa.me/… Open a chat with a manager. For WhatsApp, you can insert a pre-written first message that includes the page's name so the manager can immediately see where the inquiry is coming from.
  • Phone — link tel:, which dials the number immediately on a smartphone.
  • Online briefing in the chat — The AI assistant asks a few questions about the project, budget, and deadlines, and sends the completed brief to the manager.

No form—no spam, no plugins to update, and no lost emails. The conversation starts right away, and the chat history is saved in the messenger.

How to Track These Requests

Each button has an attribute with the event name, and a small script in the theme sends it to the dataLayer when the button is clicked:

<a href="https://t.me/…" data-event="contact_telegram">Send a message on Telegram</a>

<script>
document.addEventListener('click', function (e) {
  var el = e.target.closest('[data-event]');
  if (!el) return;
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({ event: el.dataset.event });
});
</script>

In GTM, a single «Custom Event» trigger with a regular expression is sufficient ^contact_(Telegram|WhatsApp|phone)$ and one GA4 tag generate_lead with the parameter method = built-in variable {{Event}}. In GA4 reports, you can see which channel, page, and ad campaign the visit came from.

Clicking a button is an intention, not a guaranteed lead. That’s why we verify the number of actual leads using our CRM or messaging platform, and in our ads, we optimize for a key event that correlates well with sales.

When a form is still required

A form is appropriate for placing an order in a store, scheduling an appointment, or submitting a request with files. In this case, we build it without plugins: a simple HTML form, a custom server-side handler with spam filtering, and submission of the request directly to the CRM or a Telegram bot, rather than via email. We send the event to the dataLayer only after the server has confirmed that the request has been saved, so analytics counts only actual requests.

Do you want to make sure that leads from your website don't get lost and that your ads track them correctly? Liberty makes it happen Websites without unnecessary plugins, sets up GA4 and GTM, and contextual advertising, which is optimized based on requests.