An emergency workaround for app-๐‘›๐‘›๐‘›๐‘›.marketo.com form embeds after next weekโ€™s Marketo URL change

SanfordWhiteman
Level 10 - Community Moderator
Level 10 - Community Moderator

Been reluctant to provide a short-term workaround for the rather big change coming next week to Marketo URLs. But based on recent research, I have the sense that many peopleโ€™s form embeds will be impacted on August 1st, so letโ€™s prevent a bad day in MOPSville.

 

You want to put these two scripts as high as possible in the <head> of all pages, of course replacing pages.example.com in both places with your LP domain:

<script src="//pages.example.com/js/forms2/js/forms2.min.js"></script>
<script>
   "use strict";

   MktoForms2.loadForm = new Proxy(MktoForms2.loadForm, {
      apply(target, thisArg, [instanceURL, ...rest]) {
         return Reflect.apply(target, thisArg, ["//pages.example.com", ...rest]);
      }
   });
</script>

 

By โ€œas high as possibleโ€ I mean literally right after your last <meta> tag if you can. It must run before anything else related to Marketo forms, including GTM (which might inject Marketo form tags).

 

If you have this in place, you donโ€™t have to worry about finding all the occurrences of the Forms 2.0 library and loadForm() calls throughout your code.

 

The right thing to do long-term is, of course, find and permanently fix all form embed codes  that use the old domains. But the โ€œfindingโ€ part can be tricky, as can getting the right person to implement the fix.

 

P.S. Iโ€™ll update this post with more info about why the above works, for the JS learners.

1302
4
4 Comments