
Beehiiv Form Event Listener
Track beehiiv form submission as conversion in your advertising platform, and analytics tools using Google Tag Manager, and the beehiiv form event listener (which makes it possible to fire your conversion tracking tags/pixels on successful beehiiv form submissions)
How to track beehiiv form submission with google tag manager
To track beehiiv form conversions with Google Tag Manager, all you’ll have to do is copy the event listener code and paste it into your custom HTML tag in GTM, trigger it on pageview.
<script>
(function() {
window.addEventListener("message", function(event) {
try {
if (event.origin === "https://embeds.beehiiv.com" && typeof event.data === "object" && event.data.type === "BEEHIIV_SUBSCRIBER_FORM_SUBMITTED") {
if (!sessionStorage.getItem("beehiiv_form_pushed")) {
var email = event.data.email || "";
var externalEmbedId = event.data.externalEmbedId || "";
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "download_model_form_submitted",
formType: event.data.type,
email: email,
externalEmbedId: externalEmbedId
});
sessionStorage.setItem("beehiiv_form_pushed", "true");
console.log("📤 dataLayer pushed: beehiivFormSubmitted", {
email: email,
externalEmbedId: externalEmbedId
});
}
}
} catch (e) {
console.error("Error in Beehiiv listener:", e);
}
});
})();
</script>
Next, you’ll have to navigate to triggers to create a custom event trigger type [download_model_form_submitted] which will be used to fire your marketing tags/pixels such as Google Analytics, Google ads and Facebook Pixels etc.
Also, ensure your implementation is privacy compliant. Using trigger conditions in Google Tag Manager, you can streamline your conversion to be recorded on certain pages, form IDs or user types.
This event gets all the form field data captured in the form and can be used on the successful form submission event to enrich your data.
💡 Pro Tip: To access the data fields, create a datalayer variable.