Hosting Marketo Form code in an external file | Community
Skip to main content
Grégoire_Miche2
New Participant
August 24, 2018
Solved

Hosting Marketo Form code in an external file

  • August 24, 2018
  • 1 reply
  • 1813 views

In order to deal with a especially complex web site project, we are looking into the possibility to host the Mkto form code in an external file, instead of adding the embed code in the web page.

Typically, the page will a contain a very short code:

<script src2="//info.domain.com/js/forms2/js/forms2.min.js" type="text/javascript"></script>

<form id="mktoForm_9999"></form>

<script>

var mktoFormID = 9999,

    mktoMunchkinID = "999-XXX-999",

    mktoDomain = "//info.domain.com";

</script>

<script src2="//info.domain.com/rs/999-XXX-999/images/ExternalEmbedCode.js" type="text/javascript"></script>

(I replaced scr with src2 in the <script> tags as the community editor removes the src from the <script> tags.)

Where ExternalEmbedCode.js contains all the form customized load code, starting with:

MktoForms2.loadForm(mktoDomain, mktoMunchkinID, mktoFormID, function(form) {...

The first tests seems to be working correctly.

Has anyone done such things? Any performance issue ? Any other thing to pay attention to ?

Thx for your help.

-Greg

@Sanford Whiteman​

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

It's totally fine, just an extra HTTP request.   I do exactly that for complex projects. And remember, the external JS can't itself include tokens (but if you set a global variable in the main doc to a {{token}} first, that's taken care of).

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
August 24, 2018

It's totally fine, just an extra HTTP request.   I do exactly that for complex projects. And remember, the external JS can't itself include tokens (but if you set a global variable in the main doc to a {{token}} first, that's taken care of).

Grégoire_Miche2
New Participant
August 24, 2018

Thx, as always, Sandy