Re: Push Lead to Marketo not working

Anonymous
Not applicable

Push Lead to Marketo not working

We're currently using the Push Lead To Marketo part of the API because we have an anonymous lead that needs to be sent over via the API to be created and linked to the cookie ID that is sent over.  We're setting the lookupField as 'mktToken' and sending the correct token but it's giving us an error saying that the 'mktToken' is not found and asking for an 'id' field.  In php, using the class from: GitHub - Marketo/REST-Sample-Code: Marketo REST API sample code.  We're using the 'PushLeadToMarketo.php' class.  Here is the result:

{"requestId":"17bf6#166d5d432a1","result":[{"status":"skipped","reasons":[{"code":"1006","message":"Field 'mktToken' not found"},{"code":"1003","message":"Value for requried field 'id' not specified"}]}],"success":true

Here is the lead being sent:

stdClass Object

(

    [email] => jwhitehead+fri13@test.com

    [appointmentType] => Prospective Client Phone Meeting

    [requestConsultationSubmissionDate] => 2018-11-02 13:09:05

    [requestConsultIdealTime] => 2018-11-03T21:00:00Z

    [mktToken] => id:815-VVR-763&token:_mch-dentistadvisors.com-1539376101028-96212

    [firstName] => test

    [lastName] => test

    [phone] => test

    [howDidyouhearaboutReese] => your mom

    [RequestConsultReason] => test

)

Anyone have any ideas on why this isn't working?

7 REPLIES 7
Jep_Castelein2
Level 10

Re: Push Lead to Marketo not working

I'm not familiar with the PHP code, but it appears like you've set lookupField='id' instead of 'mktToken'. Therefore it makes 'id' required and interprets 'mktToken' as a regular field (which it isn't)

SanfordWhiteman
Level 10 - Community Moderator

Re: Push Lead to Marketo not working

You need to know what JSON payload you're putting on the wire. This isn't a language-specific question, but about the contract w/the REST API, which is language-independent. (Also pls highlight JSON/code using the Advanced Editor's syntax highlighter when you do post it, so it's readable.)

In general, there are 2 problems here:

  1. mktToken isn't the Munchkin cookie, it's the mkt_tok associator query parameter. cookies is the property representing the Munchkin _mkt_trk browser cookie.
  2. You're assuming Push Lead associates all previously anonymous activity, which it does not. You need to use the Associate Lead endpoint, costing another API call.

It would also be good if you explained why you're using the REST API instead of the much more resilient and scalable Forms JS API.

Anonymous
Not applicable

Re: Push Lead to Marketo not working

The way this works, is a user goes to a landing page and then a popover displays after clicking a button to schedule a meeting.  That popover is an iframe from Appointlet.com.  Then after they fill out the schedule form, Appointlet make a webhook call to our script that will then take that form information to put it into Marketo.  The problem is that we need merge the anonymous lead to the info coming back from Appointlet.  I not really a way I could see that would make this function without using the API.

SanfordWhiteman
Level 10 - Community Moderator

Re: Push Lead to Marketo not working

Well, first of all -- though this is in its own way less scalable than I would desire -- if they're capable of relaying the form data in a webhook call, and they use form-url encoding (not JSON), then you can send that data directly to the Marketo forms endpoint.  It's not unlimited because there is (or at least historically was) a daily limit per IP address of 43,200 form posts.  But a malicious user of that workflow can never affect other API integrations, nor does it get subtracted from your REST/SOAP API limits.

Without knowing whether they have a client-side JS API, I couldn't say whether you'd be able to use the Forms JS API to send data to Marketo from the browser, which is the best practice. But merely having an IFRAME doesn't mean they can't have a cross-frame API, that's the way YouTube works for one of many examples.

SanfordWhiteman
Level 10 - Community Moderator

Re: Push Lead to Marketo not working

And in fact I can see that Appointlet absolutely does have a client-side JS API which you can use to post a form directly from the browser, no API limits nor other machinery necessary. This is a sample callback (in the main document of course, not in the IFRAME) after I make a bookiing; you can feed the important parts of the data to a Marketo form and post it in the background.

pastedImage_0.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Push Lead to Marketo not working

I now have fully operational client-side JS for this. Will add to the Products blog this weekend.

SanfordWhiteman
Level 10 - Community Moderator

Re: Push Lead to Marketo not working