SOLVED

Re: Send Lead Data from MKTO to SFDC Web-to-Lead Form

Go to solution
Valerie_Armstro
Level 10 - Champion Alumni

Hi Community!

Looking to see if someone has had experience passing/posting data from their Marketo instance to another company's SFDC Web-to-Lead form?

We've recently started working very closely with a partner and are planning to share leads with them. They have shared with us a SFDC Web-to-Lead form and I was curious if there is a way to post to that form using a Webhook (I think the answer is yes, but how to set up this particular webhook I'm not certain about).  Ideally, I would like to include it as a flow step in my trigger campaign whenever someone fills out the form on that particular partner's page.  Or maybe there is a better way of accomplishing this goal?

Thanks.

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator

Hi Valerie,

Cross-posting to Web2Lead is quite easy. The webhook URL is the SFDC endpoint. Request encoding is Form/URL. Then include the fields in the template like

fieldname1={{lead.field1}}&fieldname2={{lead.field2}}

View solution in original post

20 REPLIES 20
SanfordWhiteman
Level 10 - Community Moderator

Hi Valerie,

Cross-posting to Web2Lead is quite easy. The webhook URL is the SFDC endpoint. Request encoding is Form/URL. Then include the fields in the template like

fieldname1={{lead.field1}}&fieldname2={{lead.field2}}

Robert_Kelen3
Level 4

Sanford Whiteman Is this somehow altered by SFDC picklist fields or fields not selectable in the W2L setup (Lead Status in this case)?

Screen Shot 2017-11-02 at 1.01.16 PM.png

Between this (which successfully posts to SFDC):

<form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

<input type=hidden name="oid" value="XXXXXXXXXXX">

<input type=hidden name="retURL" value="http://">

<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="company">Company</label><input  id="company" maxlength="40" name="company" size="20" type="text" /><br>

<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>

<label for="state">State/Province</label><input  id="state" maxlength="20" name="state" size="20" type="text" /><br>

<label for="title">Title</label><input  id="title" maxlength="40" name="title" size="20" type="text" /><br>

Department:<input  id="00NA0000001ieJh" maxlength="80" name="00NA0000001ieJh" size="20" type="text" /><br>

<label for="lead_source">Lead Source</label><select  id="lead_source" name="lead_source">

<option value="Marketing: Marketo">Marketing: Marketo</option>

</select><br>

<input type="submit" name="submit">

</form>

...and this (which doesn't):

Screen Shot 2017-11-02 at 3.08.34 PM.png

It seems like something is getting lost in translation. I'm guessing that I'm missing something obvious here.

SanfordWhiteman
Level 10 - Community Moderator

What are the Activity Details for the Call Webhook Activity in a lead's Activity Log? (Click the Activity ID link.)

Robert_Kelen3
Level 4

Webhook Id:

1

Webhook Name:

Web2Lead (SFDC)

Person ID:

1

Response Code:

1000

SanfordWhiteman
Level 10 - Community Moderator

Response Code 1000 means you were calling the webhook from a batch. Can't do that directly. You have to use Request Campaign/Campaign is Requested.

Robert_Kelen3
Level 4

Thanks Sandy. Here's the corrected log then:

Webhook Name: Web2Lead (SFDC)

Request Type: http_post

Url: https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8

Pay Load:

oid=XXXXXXXXXXX&first_name=Robert2&last_name=Kelen&email=robert.kelen%2Btest2%

40leadous.com

&company=Acme&city=Unknown&state=Unknown&lead_source=Marketing%3A%20Marketo&title=Unknown&00NA0000001ieJh=Unknown&retURL=http://

Response:

Person ID: 1

Response Code: 200

SanfordWhiteman
Level 10 - Community Moderator

OK, so that's a 200 OK on the pure HTTP level, which is good... still not creating an SFDC lead?

Robert_Kelen3
Level 4

Nope. Still no lead.

SanfordWhiteman
Level 10 - Community Moderator

Set a custom header (I forgot to suggest this before) on the hook:

  Content-Type     application/x-www-form-urlencoded

Robert_Kelen3
Level 4

Added a custom header and still not seeing anything. Is there a way to know

where/how it's failing?

Robert_Kelen3
Level 4

Thanks to Sanford Whiteman's generous assist, I now know the missing piece to getting this to function properly, and wanted to share here in case anyone stumbles over this. The key is in the last line of the salesforce W2L code (<input type="submit" name="submit">). That too needs to be added to the payload template, such that the final string in this example reads like this: oid=000000000000000&first_name={{lead.First Name}}&last_name={{lead.Last Name}}&email={{lead.Email Address}}&company={{company.Company Name:default=Unknown}}&city={{lead.City:default=Unknown}}&state={{lead.State:default=Unknown}}&lead_source=Marketing%3A%20Marketo&title={{lead.Title:default=Unknown}}&00NA0000001ieJh={{lead.Department:default=Unknown}}&retURL=http://&submit=Submit

Veronica_Holme4
Level 10 - Champion Alumni

Hey - did you end up needing the custom header? I'm building this right now and thanks very much for the above as I had not added the submit, but my webhook is still failing to post, with an almost identical config to the above (just limited to email, first, last and company fields).

Also, should it be submit=submit or submit=Submit (capitalisation) - I'm down to the miniscule details here, genuinely can't think of what else to try.

Robert_Kelen3
Level 4

Veronica, two small things that stymied my early efforts in case this helps:

- field validations in Salesforce for the fields in question (make sure test values passed from Marketo are valid from SFDC's point of view; I added valid default values to prevent blanks on the tokens as well)

- webhook needs to be called from a triggered campaign (not batch or manual)

Also, in my case Submit was capitalized, though not sure if that was important.

Veronica_Holme4
Level 10 - Champion Alumni

Yep, doing all those things. Really driving me bonkers now. Thanks for the help though!

SanfordWhiteman
Level 10 - Community Moderator

If you want to DM me we can find the problem quickly, I'm sure. Robert and I only looked at it for a sec with my test server and saw the gap.

Veronica_Holme4
Level 10 - Champion Alumni

Can I confirm something? this custom header thing is bothering me because I have never had to set it before to make it work. According to the value you wrote above, the Header is Content-Type, and the Value is application/x-www-form-urlencoded ?

I have never used this setting before and I've got no idea what it is for.

Veronica_Holme4
Level 10 - Champion Alumni

WORKING! I changed the order of the layload template to put orgID last as per Sanford's example above. Should not have made a difference but it did. Thanks all - appreciate the assistance. I'll make a special effort to answer some more questions on community today to pay it forward/back/whatever

SanfordWhiteman
Level 10 - Community Moderator

Can you paste the web-to-lead HTML form into a CodePen? Then I'll tell you what webhook you need.

Veronica_Holme4
Level 10 - Champion Alumni

https://codepen.io/VHolmes/pen/KyLGxB  - obviously OID is fake

SanfordWhiteman
Level 10 - Community Moderator

Looks the same as Robert's as far as I can see/remember...

The URL is

https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8

and POST payload is

first_name={{Lead.First Name}}&last_name={{Lead.Last Name}}&email={{Lead.Email Address}}&company={{Company.Company Name}}&oid=XXXXXXXXXXXXXXX&retURL=http://&submit=Submit

Remember that all param names are case-sensitive, and set the encoding to Form/Url.