Klaviyo Form GTM Event Listener
Track Klaviyo email signup form submissions in Google Tag Manager. Capture formId, formTitle, and formEmail and fire GA4 events on klaviyoFormSubmission.
Event fired
klaviyoFormSubmissionKey variable
formIdKlaviyo
Overview
Klaviyo is an email marketing and SMS platform used primarily by eCommerce stores. Its forms, pop-ups, flyouts, embedded, dispatch klaviyoForms events. This listener intercepts those events and pushes submission data to the GTM dataLayer.
Event fired: klaviyoFormSubmission
Variables: formId, formTitle, formEmail
Credit: Julius Fedorovicius (email field added by DumbData)
Why Use This Listener
Klaviyo's forms are critical lead capture and email list growth tools. Without this listener, you cannot:
- Track email sign-ups as GA4 conversions
- Fire Meta's
Leadevent on Klaviyo sign-up - Know which Klaviyo form (pop-up vs. embedded) converts better
- Capture the email address for enhanced conversions
Common Use Cases
- Track newsletter and discount email sign-ups as GA4 conversions
- Fire
Leadevent to Meta on Klaviyo form submission - Measure pop-up vs. embedded form conversion rates
- Use sign-up events to build Google Ads RLSA audiences
- Send hashed email to Google for Enhanced Conversions
- Connect Klaviyo sign-ups to purchase data in GA4
How It Works
Klaviyo dispatches a custom event named klaviyoForms on the window. The listener filters for submit event types and pushes the form ID, title, and email to the dataLayer.
Installation
<!-- GTM Custom HTML Tag: Klaviyo Form Listener -->
<script>
window.addEventListener('klaviyoForms', function(e) {
if (e.detail.type === 'submit') {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'klaviyoFormSubmission',
'formId': e.detail.formId,
'formTitle': e.detail.metaData.$source,
'formEmail': e.detail.metaData.$email
});
}
});
</script>Fire on: All Pages (Pageview).
Data Layer Output
{
"event": "klaviyoFormSubmission",
"formId": "RaMkJd",
"formTitle": "Summer Sale Popup",
"formEmail": "customer@example.com"
}Trigger Configuration
Trigger Type: Custom Event
Event Name: klaviyoFormSubmission
Variables to Capture
| Variable Name | DL Key | Example |
|---|---|---|
| DLV – Klaviyo Form ID | formId | "RaMkJd" |
| DLV – Klaviyo Form Title | formTitle | "Summer Sale Popup" |
| DLV – Klaviyo Email | formEmail | "user@example.com" |
GA4 Mapping Recommendations
| GA4 Event | Parameter | Value |
|---|---|---|
sign_up | method | "klaviyo" |
sign_up | form_id | DLV – Klaviyo Form ID |
sign_up | form_name | DLV – Klaviyo Form Title |
sign_up | email | DLV – Klaviyo Email (hashed for Enhanced Conversions) |
Debugging
| Problem | Cause | Fix |
|---|---|---|
| Event not firing | klaviyoForms event not dispatched | Confirm Klaviyo script is loading |
formEmail is empty | Email field not named email | Check Klaviyo form field name mapping |
| Fires on open, not submit | Missing type === 'submit' filter | Add the filter check |
Best Practices
- Use
sign_upnotgenerate_leadfor email subscriptions, better GA4 taxonomy alignment - Hash the email before pushing to dataLayer if using Enhanced Conversions
- Capture
formTitle, it makes GA4 reports more readable than raw form IDs - Create per-form-type events, popup sign-ups vs. embedded sign-ups have different intent signals
Performance Considerations
- One
window.addEventListenercall, zero performance impact - The
klaviyoFormsevent fires asynchronously after Klaviyo processes the submission