Hi everyone 👋
I’m running into a persistent issue while integrating Marketo Forms inside a Next.js (React) application for Seismic’s website.
The issue:
When navigating between two pages that both contain Marketo forms — for example:
https://www.seismic.com/resources/reports/g2-grid-spring-2025/
The “Connect With Us” button will take you to get a demo (also a Marketo form)
— the Marketo forms conflict with each other.
Once a user visits one page and then navigates to another (SPA routing, not full reload), the Marketo form from the first page persists in memory (window.MktoForms2 cache). This leads to:
Duplicate or multiple form instances (window.MktoForms2.allForms() keeps old forms)
Conflicting success handlers — one form overrides another
Stale or broken styling when switching between form types (inline vs popup)
Programmatic reloads (router.reload() or window.location.reload()) causing further side effects like state loss and flickering
I’ve already tried:
Clearing window.MktoForms2.allForms() and calling destroy() on each form
Deleting window.MktoForms2 and reloading the script
Using dynamic imports and script loaders
Reloading the page programmatically on route changes
…but none of these provided a stable solution inside a single-page app context.
Has anyone successfully isolated or reset Marketo Forms between routes in a React or Next.js application without a full page reload?
Would implementing a middleware or hook (to manage Marketo’s global state between page transitions) be a better long-term fix?
Any code patterns, examples, or best practices to handle this cleanly would be super helpful. 🙏
Environment details:
Framework: Next.js 14+
Integration: Marketo Forms 2.0 (MktoForms2 global script)
Pages involved: Both use different Marketo form IDs
Observed in Chrome and Edge
Thanks in advance to anyone who’s handled this kind of Marketo/SPA integration before!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
I think this issue has the same root cause as yours. Try the solution suggested here:
https://nation.marketo.com/t5/product-discussions/marketo-forms-in-single-page-applications-incorrec...
In theory, reloading the script after flushing the window.MktoForms2 object should work. What issues are you running into with that approach?
Hope this helps
Hi,
I think this issue has the same root cause as yours. Try the solution suggested here:
https://nation.marketo.com/t5/product-discussions/marketo-forms-in-single-page-applications-incorrec...
In theory, reloading the script after flushing the window.MktoForms2 object should work. What issues are you running into with that approach?
Hope this helps
Hi @EstebanBustamante,
Thank you so much, It resolved most of the issues i had with Forms2.
In theory, reloading the script after flushing the window.MktoForms2 object should work. What issues are you running into with that approach?
Of course, I have this one side effect which happens when ever I come back to the original page.
Form completely disappears due to flushing out the existing script ( Including cache ) But I will figure it out.
Thank you so much @EstebanBustamante.
This really help me alot.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies