Hosting Marketo Form code in an external file | Community
Skip to main content
Grégoire_Miche2
Level 10
Aug 24, 2018 9:01 AM UTC
Solved

Hosting Marketo Form code in an external file

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.
SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Aug 24, 2018 4:29 PM UTC

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).

2 replies

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Aug 24, 2018 4:29 PM UTC

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).

Translate
Grégoire_Miche2
Level 10
Aug 24, 2018 5:03 PM UTC

Thx, as always, Sandy

Translate