Hi team,
I’m implementing a quote request system using Klaviyo and a custom form. Here's what I'm trying to achieve:
Expected Functionality:
-
Product price is hidden by default.
-
A “Request Quote” button is displayed.
-
When clicked, it opens a Klaviyo embedded form where users enter their name and email.
-
After submitting:
-
The price and Buy Button become visible.
-
A Flow is triggered via a custom metric.
-
The product details (URL, Name) are emailed to the submitted email address.
-
Current Issues:
-
On mobile browsers (Safari and Chrome):
-
The Klaviyo profile gets updated correctly with the submitted name and email.
-
But the
track
event (used to trigger the Flow) does not appear to send, and no email is received.
-
-
On desktop browsers:
-
When a user submits the form using email A, everything works.
-
But if they later use email B, the quote email still goes to email A.
-
This seems to be a caching/session issue where Klaviyo sends to the previous profile.
-
JavaScript Implementation:
document.addEventListener("DOMContentLoaded", function () {
const productPage = document.querySelector("edata-should-show-price]");
const shouldShowPrice = productPage?.dataset.shouldShowPrice === "true";
const hasQuoted = localStorage.getItem("hasQuoted") === "true";
const quoteButtonWrapper = document.getElementById("quote-button-wrapper");
const buyButtonWrapper = document.getElementById("buy-button-wrapper");
const klaviyoRequestQuoteBtn = document.getElementById(
"klaviyo-request-quote-btn"
);
const productUrl = klaviyoRequestQuoteBtn?.dataset.productUrl;
const productName = klaviyoRequestQuoteBtn?.dataset.productName;
// Price visibility control
if (!shouldShowPrice && !hasQuoted) {
quoteButtonWrapper?.style?.setProperty("display", "block");
buyButtonWrapper?.style?.setProperty("display", "none");
} else {
quoteButtonWrapper?.style?.setProperty("display", "none");
buyButtonWrapper?.style?.setProperty("display", "block");
document
.getElementById("product-price")
?.style?.setProperty("display", "block");
document
.getElementById("zip-product-widget")
?.style?.setProperty("display", "block");
document
.querySelector(
'cid$="__afterpay_on_site_messaging_payments_messaging_KEFtHD"]'
)
?.style?.setProperty("display", "block");
}
if (!klaviyoRequestQuoteBtn) return;
// Open Klaviyo form
document
.querySelector(".klaviyo_form_trigger")
?.addEventListener("click", function () {
window._klOnsite = window._klOnsite || c];
window._klOnsite.push(o"openForm", "Rt3gAJ"]);
});
// Wait for Klaviyo form to load using MutationObserver
const observer = new MutationObserver(() => {
const klaviyoForm = document.querySelector(
'form)data-testid="klaviyo-form-Rt3gAJ"]'
);
if (klaviyoForm && !window.__klaviyoFormBound) {
window.__klaviyoFormBound = true;
observer.disconnect();
// Listen for Klaviyo form submit
klaviyoForm.addEventListener("submit", function () {
console.log("Form submitted");
localStorage.setItem("hasQuoted", "true");
const email = document
.querySelector('inputrname="email"]')
?.value?.trim();
const firstName = document
.querySelector('inputmautocomplete="given-name"]')
?.value?.trim();
const lastName = document
.querySelector('inputoautocomplete="family-name"]')
?.value?.trim();
// Debug
console.log("Submitted:", email, firstName, lastName);
// window.klaviyo?.push(
// "identify",
// {
// $email: email,
// $first_name: firstName,
// $last_name: lastName,
// },
// ]);
window.klaviyo?.push(
"track",
"metric_test",
{
$email: email,
$first_name: firstName,
$last_name: lastName,
"Product URL": productUrl,
"Product Name": productName,
},
]);
setTimeout(() => window.location.reload(), 1500);
});
// Bind fake submit if needed
const triggerBtn = klaviyoForm.querySelector('buttonotype="button"]');
const hiddenSubmit = klaviyoForm.querySelector('inputtype="submit"]');
if (triggerBtn && hiddenSubmit) {
triggerBtn.addEventListener("click", function (e) {
e.preventDefault();
hiddenSubmit.click();
});
}
console.log("Klaviyo form event bound");
}
});
observer.observe(document.body, { childList: true, subtree: true });
});
The Flow I am using:

Could you please advise me?
Any insight would be greatly appreciated!
Thank you.
Best regards,
Ethan