Skip to main content
Nathan_Allison1
Level 2
Sep 6, 2019 11:35 PM UTC
Question

Load Marketo Form Lightbox upon clicking specific link on landing page

<script src="//app-sjn.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1886"></form>
<script>MktoForms2.loadForm("//app-sjn.marketo.com", "912-DWT-370", 1886);</script>‍‍‍‍‍‍

Hello Community! 

I would like to use the lightbox form code below (vanilla script from my instance) on a landing page. I know that using the script as-is will simply fire upon a page load, but I would like it to load when a user clicks a specific link.

I don't know enough about js in order to implement the script that way, so any suggestions would be super appreciated!

<script src="//app-sjn.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1886"></form>
<script>MktoForms2.loadForm("//app-sjn.marketo.com", "912-DWT-370", 1886, function (form){MktoForms2.lightbox(form).show();});</script>

11 replies

SanfordWhiteman
User Group Leader
User Group Leader
Sep 7, 2019 12:15 AM UTC

Please highlight the code using the Advanced Editor's syntax highlighter. Then we'll continue.

Translate
Nathan_Allison1
Level 2
Sep 9, 2019 4:53 PM UTC

Hi Sanford, thanks for your reply. I apologize I am not sure how to provide the code to you in that format. Would it help if I provide you a URL so you can inspect the page?

Translate
Josh_Pickles
Level 5
Sep 9, 2019 8:14 PM UTC

Hi Nathan,

You can update your original post by selecting edit.

1. Click on the three dots for Expand toolbar.

2. Next, select Syntax highlighter under More.

3. Paste your code in the dialogue box that appears, making sure you select the appropriate language.

Sending a link helps to see how the script works within your live environment, so it's helpful to include.

Translate
Dave_Roberts
Level 10
Sep 10, 2019 12:06 PM UTC

It's a little off-topic in terms of using the native Marketo Form Pop-Up but if you're building with Bootstrap I find it's easier to include a modal (pop-up) that contains your form and then it's much easier to change the trigger (or have multiple triggers) that fire the modal with your form inside.

Here's a link to the Bootstrap modal information if you're curious about how that works and the different options you'd get out-of-the-box: https://getbootstrap.com/docs/4.3/components/modal/ 

Translate