Associate lead from external app to marketo

Level 2

Associate lead from external app to marketo

In my external website (which is a react application) on click of a button (sign up button), I need to send marketo email.

When I embed marketo form, enter data in the form and submit, lead is getting associated in marketo. Email is also getting triggered by smart campaign.

However as per my UI requirements, I can't have marketo form in my page.

I am trying out the approach mentioned here -

I am calling munchkins associateLead function when a button is clicked in my page. 

Following is the code:




document.addEventListener("click", function (event) {
          if ( === "SignUP") {
                Email: decodeURIComponent(""),
                FirstName: decodeURIComponent("Saurabh"),
                LastName: decodeURIComponent("Mehta"),



But in the network tab I could see 401 invalid request token error.

Here is the request URL in network tab -



What am I missing here?

I am really stuck at this point. Really appreciate any inputs on this issue.


Level 10 - Community Moderator

Re: Associate lead from external app to marketo

You can post a hidden Marketo form, there's no need to affect your UI.


associateLead can only be used if the hash is generated on your server. It must not be generated in the browser. And since it requires that you know the Email Address in both cases, you should use the hidden form. The main reason not to use the form is if the extra Filled Out Form in the ActLog is truly disruptive.