Funnel & CRM platforms

Kartra Opt-in Form Listener for GTM: GA4, Enhanced Conversions and Meta CAPI

Tracks Kartra opt-in form submissions in GTM from the confirmation, form replacement or redirect, with failure events and Enhanced Conversions data.
EC-ready · Redirect-safe · CAPI dedupe · Tracks failures

Free and MIT licensed. Paste it into a GTM Custom HTML tag. No plugin or code change on the site.

At a glance

Version

3.0.1

Updated

July 5, 2026

Success event

kartra_form_success

Failure event

kartra_form_failed

Detection

Confirmation render + form replacement

Redirects

Yes: pagehide fallback and same-domain thank-you recall

Enhanced Conversions

Yes: email, phone, name, optional SHA-256

Dependencies

None

Tag size

42.3 KB

License

MIT

What lands in your dataLayer

One clean event per real lead

Every success carries an event ID for Meta deduplication, the detection method that fired, and normalized contact fields you can map straight into Enhanced Conversions. Keep the PII keys out of GA4.

				
					{
  event: "kartra_form_success",
  ec_event_id: "uuid-v4",
  ec_detection_method: "confirmation_render",
  ec_tracker_version: "3.0.1",
  ec_name: "Jane Doe",
  ec_email: "jane@example.com",
  ec_phone: "+15551234567",
  form_url: "https://example.com/landing-page",
  form_cta: "Get Access",
  form_platform: "kartra",
  form_position: "top",
  form_index: 1,
  form_id: "abc123",
  ec_raw_fields: {
    email: {
      value: "jane@example.com",
      type: "email",
      _bucket: "email"
    }
  }
}
				
			

Why this listener exists

Kartra has no public JavaScript event for a completed opt-in, and most Kartra funnels redirect to the next step. That leaves page-view tracking, which counts refreshes and direct visits.

This listener watches the form’s own state, the confirmation it renders and the redirect window, so a lead counts once and carries the contact data your ad platforms need.

Most form tracking fires on a button click or a thank-you page view. Clicks count validation failures and repeat clicks. Thank-you page views count refreshes, back-button visits and bookmarked links. This listener watches what Kartra actually renders, so the event is much closer to a real lead.

How it detects a real submission

kartra_form_success fires on the first of these success paths:

  • An inline confirmation render
  • The form removed or replaced after submit
  • A redirect, caught on pagehide inside the submit window
  • A same-domain thank-you page, matched to recent stored form data

kartra_form_failed fires when Kartra renders a validation error after the visitor has interacted with the form.

Every event carries ec_detection_method, so you can segment reports by how each lead was detected and see which signals your site actually uses.

ec_detection_method Event What it means
confirmation_render Success A confirmation or thank-you message rendered in place of the form
form_removed Success The form was removed or hidden after a valid submit
stored_recall Success Same-domain thank-you page, matched to data stored at submit
pagehide Success The page unloaded inside the submit window with no error showing (fallback)
error_class Failure The form gained the platform’s error class
error_render Failure An error message rendered after the visitor interacted

Install it in Google Tag Manager

  1. Download the GTM tag above, or copy kartra-form-tracker.gtm.html from the GitHub repository.
  2. In GTM, create a Custom HTML tag and paste the file in. It already includes the <script> wrapper.
  3. Trigger it on All Pages (Page View), or on Consent Initialization if your consent setup needs the tracker available early.
  4. Create a Custom Event trigger for kartra_form_success. Use the regex ^kartra_form_(success|failed)$ if you also want failures.
  5. Create Data Layer Variables for the keys you need (table below), then attach your GA4, Google Ads, Meta or server-side GTM tags to the trigger.
  6. Open Preview, submit a real test form and confirm kartra_form_success appears with the expected ec_detection_method. Then publish.

Retire any old click or thank-you page conversion for the same form, otherwise each lead is counted twice.

Events and dataLayer keys

Key What it holds
event kartra_form_success, kartra_form_failed, ec_form_interaction (first real input) or ec_tracker_initialized (script loaded)
ec_event_id UUID per event. Pass it to Meta as the event ID so browser and CAPI events deduplicate
ec_detection_method Which success or failure path fired (see above)
ec_tracker_version Script version, useful when you audit containers later
ec_email, ec_phone, ec_name Normalized PII from the form (phone in E.164 where possible). Removed when PII consent is denied
ec_email_sha256, ec_phone_sha256 SHA-256 hashes, added when hashPii: true (needs HTTPS)
ec_raw_fields Every captured field with a _bucket classification. Keep it out of GA4
form_id, form_platform Form identifier and platform name
form_position, form_index Where the form sits on the page (top, middle, footer) and its order, for multi-form pages
form_url, form_cta Page URL and the submit button text
ec_pii_redacted true when PII consent is denied and PII keys were stripped

Using it for Enhanced Conversions and Meta CAPI

  • Google Ads Enhanced Conversions: map ec_email and ec_phone (or the _sha256 versions) into a User-Provided Data variable on your conversion tag.
  • Meta Pixel and CAPI: send ec_event_id as the event ID on both the browser and server event so Meta counts the lead once.
  • GA4: do not send raw ec_* PII or ec_raw_fields to GA4. Its terms prohibit PII in event parameters. Send form_id, form_platform and ec_detection_method instead.
  • Duplicates: with dedupe: true (the default), a repeat success for the same form, email or phone within 5 minutes is suppressed.

Configuration and consent

Set window.EC_FORM_CONFIG before the tag loads to change the defaults:

window.EC_FORM_CONFIG = {
  debug: false,            // [EC] console logs, Preview only
  hashPii: false,          // add ec_email_sha256 / ec_phone_sha256
  dedupe: true,            // suppress repeat success within 5 min
  ttlMs: 600000,           // freshness window for thank-you recall
  defaultCountryCode: "1", // phone normalization fallback
  extraThankYouPatterns: [] // extra thank-you URL substrings
};

The tracker checks consent before it fires or writes storage. It auto-detects Google Consent Mode v2, OneTrust and Cookiebot. With analytics consent denied, nothing fires and nothing is stored. With PII consent denied, events still fire but email, phone, name and hashes are removed. Any other CMP can be wired in with window.EC_FORM_CONSENT_CHECK. If no CMP or override is found, the tracker assumes full consent, so match it to your own legal requirements.

Test it before you publish

  • Submit a valid form. Expect one kartra_form_success.
  • Submit with a required field empty. Expect kartra_form_failed and no success event.
  • Fix the error and resubmit. Expect one success (recovery is allowed).
  • Refresh the confirmation or thank-you page. Expect nothing new.
  • If the page has two forms, submit each and check form_position and form_index.
  • Run window._ecFormTrackers.kartra.status() in the console to see version, consent state, attached forms and the last event.

Troubleshooting

  • No ec_tracker_initialized in Preview? The tag is not firing on that page, or consent for analytics is denied.
  • Events in Preview but not live? Make sure the container is published, and that a cache or script optimizer (for example WP Rocket delay JS or Cloudflare Rocket Loader) is not deferring GTM.
  • Set debug: true in EC_FORM_CONFIG to see [EC] logs while testing.

Known limitations

  • pagehide is a fallback, not a perfect confirmation signal.
  • A redirect to a different domain (for example a Kartra-hosted next step) cannot use same-domain recall.
  • Kartra markup may change. Test on the live page before publishing.
  • Bot or spam submissions that pass the platform’s own validation still count as success.
  • Phone normalization is best-effort. The raw value stays in ec_raw_fields when PII consent allows it.

Changelog

  • 3.0.1: first public standalone release. Confirmation-render detection, success and failure events, consent gate (Consent Mode v2, OneTrust, Cookiebot), PII redaction, optional SHA-256 hashing, 5-minute dedupe, ec_event_id, thank-you recall and the status() debug API.

On this page

Want it installed and verified?

We install the listener, wire GA4, Google Ads Enhanced Conversions and Meta CAPI, and check the numbers against your CRM.

Keep going

More GTM form listeners

Multi-platform

Universal GTM Form Tracker: One Tag for Nine Form Platforms

One GTM tag that detects the form platform on the page and tracks real confirmations for Gravity Forms, Elementor Pro, Contact Form 7, WPForms, GoHighLevel, Unbounce, SwipePages, Kartra and Squarespace.
9 platforms, One tag, CAPI dedupe, Container import
Embedded form builders

Jotform Listener for GTM: Track Redirecting Forms Without Thank-You Page Triggers

Tracks Jotform submissions in GTM even when the form redirects to a thank-you page, and never counts a refresh, back button or direct visit to that page.
Redirect-safe · EC-ready (source embeds) · CAPI dedupe · 88 tests
v3.3.0-jotform.1
WordPress forms

Gravity Forms Listener for GTM: GA4, Enhanced Conversions and Meta CAPI

Tracks real Gravity Forms submissions in GTM, including AJAX confirmations, postback pages and same-domain thank-you redirects, with hashed email and phone for Enhanced Conversions.
EC-ready · Redirect-safe · CAPI dedupe · Tracks failures

When the numbers still do not match

Your form fires. Does the conversion match the CRM?

A listener fixes detection. If Google Ads, Meta and GA4 still disagree with your actual leads, the problem is usually elsewhere in the container, the consent setup or the CRM hand-off.