How to Integrate with Marketo

Integrating with Marketo is easy. 

1. Copy/paste the code below into one of your "HTML" slots in your Lightbox editor 

2. Replace [MARKETO-FORM-ID] with your Marketo Form ID. It should look something like this  mktoForm_8906.

3. Replace [NUMBER-ID-OF-MARKETO-FORM] with your actual Marketo Number ID. For example if your form ID is mktoForm_8906 your number ID would be 8906

4. Replace [MUNCHKIN-ID] with your actual form Munchkin ID. It should look something like this 393-RAC-168.

5. The src URLs will also need to change based on your specific Marketo code.

6. The code below is if you are collecting the following fields:

  • First Name
  • Last Name
  • Email
  • Phone
  • Address
  • Zip

If you only want to collect email only use the email code clause. If you need more fields than this they can be added using the same format.

<script src='https://app-sj02.marketo.com/js/forms2/js/forms2.min.js'></script>
<form id='[MARKETO-FORM-ID] '></form>
<script>
setTimeout(function(){
    MktoForms2.loadForm('https://app-sj02.marketo.com', '[MUNCHKIN-ID]', [NUMBER-ID-OF-MARKETO-FORM]);
    $('#[MARKETO-FORM-ID] ').toggle();
}, 2000);

$('#button1').on('click', function() {
    if (document.getElementById('Email') !== null && $('#form_input_email').length)
     document.getElementById('Email').value = $('#form_input_email').val();
    else if (document.getElementById('Email') !== null)
     document.getElementById('Email').value = 'NotProvided@EmailAddressNotProvided.com';
    else if ($('#form_input_email').length) 
     $('<input>', { type: 'hidden', id: 'Email', name: 'Email', value: $('#form_input_email').val() }).appendTo('#[MARKETO-FORM-ID] ');
    
    if (document.getElementById('FirstName') !== null && $('#form_input_first_name').length)
     document.getElementById('FirstName').value = $('#form_input_first_name').val();
    else if (document.getElementById('FirstName') !== null)
     document.getElementById('FirstName').value = 'NotProvided';

    if (document.getElementById('LastName') !== null && $('#form_input_last_name').length)
     document.getElementById('LastName').value = $('#form_input_last_name').val();
    else if (document.getElementById('LastName') !== null)
     document.getElementById('LastName').value = 'NotProvided';

    if (document.getElementById('MobilePhone') !== null && $('#form_input_phone').length)
     document.getElementById('MobilePhone').value = $('#form_input_phone').val();
    else if (document.getElementById('MobilePhone') !== null)
     document.getElementById('MobilePhone').value = '111-111-1111';

    if (document.getElementById('Address') !== null && $('#form_input_custom1').length)
     document.getElementById('Address').value = $('#form_input_custom1').val();
    else if (document.getElementById('Address') !== null)
     document.getElementById('Address').value = '111 Main St';


    if (document.getElementById('PostalCode') !== null && $('#form_input_custom2').length)
     document.getElementById('PostalCode').value = $('#form_input_custom2').val();
    else if (document.getElementById('PostalCode') !== null)
     document.getElementById('PostalCode').value = '11111';

    $('.mktoButton').click();
    console.log('mktoButton (clicked) form should be submitted...');
});
</script>