SOLVED

capture marketo field to send to 3rd party from client browser

Go to solution
frudman
Level 1

capture marketo field to send to 3rd party from client browser

We're capturing customer emails from a marketo form on one of our site page.

That email is sent to Marketo/DB.

 

We'd like to ALSO send that email separately to another server from that page directly.

 

Is there a simple way to access that email so that I can reuse it in a different (non-marketo) script on that page.

 

The full context of the problem is as follows: the page contains affiliate converting tracking codes from `Impact.com` and for those pages (that contain the code) we need to pass Impact.com back that email. (so not for all visitors to that page, just those whose page came from our affiliate partners).

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Darshil_Shah1
Level 10 - Community Advisor

Re: capture marketo field to send to 3rd party from client browser

Yes, you can use Marketo form2.0 JS to access the Email Address (and the other form fields the person submits on the form). Check out the code in “Read Form Field Values on Form Submit” example on the forms2.0 JS usage example page.

View solution in original post

8 REPLIES 8
Darshil_Shah1
Level 10 - Community Advisor

Re: capture marketo field to send to 3rd party from client browser

Yes, you can use Marketo form2.0 JS to access the Email Address (and the other form fields the person submits on the form). Check out the code in “Read Form Field Values on Form Submit” example on the forms2.0 JS usage example page.

Jo_Pitts1
Level 10 - Community Advisor

Re: capture marketo field to send to 3rd party from client browser

@frudman ,

Does the third party have an API you can hit without exposing secure keys on the client side?  If not, you should definitely not be adopting a client side approach.  You really should be using a Marketo webhook.

Regards

Jo

 

 

frudman
Level 1

Re: capture marketo field to send to 3rd party from client browser

I'm not sure but it's much easier (for our purposes) to simply grab-it-and-go from that page. The following page remains a standard template page (nothing specific based on user) and I'm not familiar with prior page (coming from a different company) to worry about changes there. Simplest is best is the solution provided is simple (enough!) for me to implement. 

SanfordWhiteman
Level 10 - Community Moderator

Re: capture marketo field to send to 3rd party from client browser

That’s incorrect. Using onSubmit isn’t “simpler”, because it has an inherent race condition which will cause your external calls to fail randomly (i.e. when the Thank You URL is loaded, it aborts all outstanding remote connections).

 

You should be using onSuccess if you want to have an actual working solution.

frudman
Level 1

Re: capture marketo field to send to 3rd party from client browser

noted, replaced with your code.

but fyi, the return false prevented thankyou page from displaying so removed that bit.

thanks for the info.

freddy

SanfordWhiteman
Level 10 - Community Moderator

Re: capture marketo field to send to 3rd party from client browser

return false; is required — now you just have another race condition!

 

You set document.location.href when (and only when) your remote call is complete.

SanfordWhiteman
Level 10 - Community Moderator

Re: capture marketo field to send to 3rd party from client browser

This would be better done in onSuccess, not onSubmit, because onSuccess means the data was completely sent to Marketo.

 

MktoForms2.whenReady(function(readyForm){
  readyForm.onSuccess(function(submittedValues,thankYouURL){
    // do something with the submittedValues object
    return false;
  });
});

 

frudman
Level 1

Re: capture marketo field to send to 3rd party from client browser

don't disagree through for our purposes the data sent is based on where the user came from, regardless of whether or not the data makes it to marketo after submit (it does matter but not so significant in terms of executing the impact script).