Marketo Webhooks With Marketo API

Anonymous
Not applicable

Marketo Webhooks With Marketo API

Odd question but I am wondering if its possible to use a marketo webhook to call and return data with either the soap or rest api for the same instance in marketo.

I have a unique use case where I want to merge two leads but need to do it in a smart campaign and I'm wondering if I can do that all contained within marketo or if I will need to use an external script to accomplish this.

If anyone has code examples that would be super as well I'm not very proficient with api syntax and webhooks.

25 REPLIES 25
Josh_Hill13
Level 10 - Champion Alumni

Re: Marketo Webhooks With Marketo API

I believe there is an example on RingLead's site if you look for their webhook guide.

What precisely do you want to do? Marketo dedupes emails before it sends any emails out. What you want may already exist with Ringlead or another tool.

Anonymous
Not applicable

Re: Marketo Webhooks With Marketo API

Hi Josh thanks for your comment.

I am creating a contact record in salesforce via the rest api and using the data from a new lead in marketo to generate it.  Once the interval sync occurs that will cause there to be two leads in marketo with the exact same information as marketo doesn't allow me to force a relationship between those records at the point of creation.

So I need a programmatic way to cause a merge of the original marketo lead that triggered the contact creation webhook and the new marketo lead that was generated from the interval sync so I don't have duplicate records in marketo.  Does that help clarify? Our company creates contacts first in salesforce which is confusing I know but this would be a workaround that would allow that to happen.

Thanks,

Dave.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Webhooks With Marketo API

David, what are the conditions that prohibit you from waiting < 5m for the Marketo lead to sync to SFDC?

Not to say I haven't seen a similar situation -- in fact, we are dealing with one now.  But that's because we have a form creating users in SFDC and we can't switch that form to be a Mkto form.

I'd like to know the particulars of your situation because there may be a better approach.

While it is possible, after a fashion, to call Mkto APIs from Marketo 'hooks, it is clumsy, not particularly scalable, and if the flows are not managed tightly will lead to infinite loops.

Anonymous
Not applicable

Re: Marketo Webhooks With Marketo API

Hey Sanford Whiteman​,

We have a similar problem and I'm interested in how you dealt with this.

We are actually using a webhook to get sessionId from SFDC SOAP, and then a second webhook to create a contact. SFDC then deals with attaching to account. (i know this isn't the best way, but I currently don't have the time/budget or approval to create an intermediary).

Problem is, Mkto creates a duplicate lead as soon as the contact appears in SFDC.

I have no access to SFDC ID in Mkto and can't see any other way to prevent the dupes.

Thoughts?

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Webhooks With Marketo API

You'll have to give more of an explanation for why you're in this predicament.

You say you don't have access to the SFDC ID -- is this because the Marketo lead in whose context you're running the webhook isn't the same person you're trying to create in SDFC?

Anonymous
Not applicable

Re: Marketo Webhooks With Marketo API

The Marketo contact is the same person that I am creating in SFDC

I don't have access to the SFDC ID in a flow step or as an available field to map a Webhook response to.

Shortly after I use Webhook to create contact in SFDC Maketo creates dupe record.

I'm kind of at a loss as to how to prevent this from happening. My org doesn't use lead records in SFDC, we've investigated creating leads and converting, but that creates new account and opportunity.

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Webhooks With Marketo API

My org doesn't use lead records in SFDC, we've investigated creating leads and converting, but that creates new account and opportunity.

You can use Apex to short-circuit the Account + Oppo. I think that's the way to go.  Easier all around.

Otherwise you would have to run a merge of the initial Marketo Lead and the SFDC-created Marketo Contact, which is going to be more fragile.

Jon_Wu
Level 4

Re: Marketo Webhooks With Marketo API

Sanford, I have this exact issue, and with some help from Marketo, we solved this in a rather brute force way. I'm wondering if you have any more efficient or reliable ways to handle this.

We create leads in Salesforce and Marketo simultaneously in many cases from our e-commerce site. Any time you enter your email on our site (usually not in a Marketo form), we add you to Salesforce and our other account systems for CRM and tracking, and call associateLead in Munchkin so that all the user's activity is associated with them immediately in all systems.

Of course, since Marketo doesn't deduplicate Salesforce synced leads, this will result in a duplicate within 5 minutes when the Salesforce lead is synced back to Marketo.

To ditch the duplicate as quickly as possible to avoid conflicts in behavioral scoring or unsubscribe preferences, or other fields, we use a Smart Campaign to fire a webhook to our own endpoint, which deduplicates the lead by finding all leads with the same email, and merging them all into the Salesforce one. This in theory works decently (not really, see below), but it still uses 2 API calls and isn't ideal from that perspective, because we'll hit API limits if we suddenly appear on national TV or have some unexpectedly large event, but perhaps the limits issue is just unavoidable with the way Marketo limits work.

The worst part is, this doesn't actually work reliably due to data consistency bugs on Marketo's side. When we first implemented this, our find dupes, then merge behavior wasn't working consistently. After talking with support, we determined that the API to find leads didn't consistently return all the leads with the same email address if the leads were recently created. To get around this, we fire a deduplication webhook as normal, but then wait 3 minutes and do it again, in case the first one didn't work.

In rarer cases, a lead may appear in Salesforce, but not appear in Marketo, so we also have to deduplicate all new leads that appear in Marketo, that aren't from Salesforce. Again, we have the same consistency bug with the API not returning all leads, so we try once, wait 3 minutes, then try again.

In all, this means every lead that gets created results in 4 API calls to find duplicates (1 for the lead starting in Marketo, 1 for the Salesforce lead synced into Marketo, and double those for retries), and 1 API call to merge them. It's been working fairly reliably (except when we hit API concurrency limits), but the number of API calls is way too many.

While we could always wait 3 minutes, this doesn't bode well for users on multiple devices doing things really quickly in real time. The longer a lead is a duplicate, the more behavioral and scoring data will be lost during the merge.

There's got to be a better way... Any suggestions?

SanfordWhiteman
Level 10 - Community Moderator

Re: Marketo Webhooks With Marketo API

Jon, there's certainly a more efficient way! You're in a not-rare -- not to say "common," I guess -- situation, where the lead is known to SFDC first, but you want to associate the Munchkin session. This happens with Web-2-Lead and 3rd-party forms and other environments as well.

The answer is: don't call associateLead from the client (nor from your server). Let the sync create the person in Marketo.  But include on the lead a field that stores the Munchkin cookie value (_mkto_trk). When the lead is created or when this field changes, use a webhook from Marketo to associate the cookie with the lead. Takes one API call total.

We actually have a field that holds multiple Munchkin cookies (in case the person goes in from more than one device before the next sync, unlikely but possible). But you can work with just one at a time in most cases.