Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

Highlighted
Anonymous
Not applicable

Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

Hello,

Is it possible to use the Marketo REST API to provide a Lead ID, Marketo Program ID, then result with a true/false response?

Thank you!

Tags (1)
8 REPLIES 8
Highlighted
Level 10 - Community Moderator

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

Not Smart Campaigns, since those aren't exposed (yet).

If you're looking for an isMemberOfProgram API like the isMember (of List) call I also think you're out of luck. You have to do it in reverse. The exception I can think of is when you only have one relevant status in a program: then you could call status and re-set the status and it'll tell you if the lead is in the program or not. Or maybe I'm not thinking of another way to rotate this... what's the use case, anyway?

Highlighted
Anonymous
Not applicable

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

It is a simple one: present the Marketo form only for those who haven't submitted that specific form (that form being unique in a Marketo Program). And, if the Lead is already in the Marketo Program, present the content instead of the form.

That Marketo Program is a Nurture program or more like a subscription, so I want to make sure they are Subscribed instead of just presenting the content to any known lead in the database.

Highlighted
Level 10 - Community Moderator

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

Even if you had an API call that's possible here, it would be a gaping DoS vulnerability to look someone up via REST just because they visited the page.

Instead, maintain a history field containing the program ID ({{Program.Id}}) when someone submits the form in that program.  Check if that field already contains the current program ID, if so just take them to the content, if not gate them.

Highlighted
Anonymous
Not applicable

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

You are right, I will be doing too many calls to the API. Ok. Adding a history field sound like a good idea, however, what I will do is add a cookie once the form is submitted, so I can check for that cookie next time the Lead visits the page. I was just wondering if there could be a more elegant solution.

Highlighted
Level 10 - Community Moderator

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

Well, a cookie won't work across devices, so that doesn't give complete parity with what you want.

I think embedding the {{Program.Id}} value and the {{Lead.Program Form History}} field in JS and conditionally loading the form is quite elegant.

Highlighted
Anonymous
Not applicable

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

Oh, sound good. I am not fully understanding the solution.

You are saying: Adding Program ID and Program Form History as hidden fields in the form and check those in JS? I believe that if the match, serve the content using AJAX I believe.

That Program Form History is a Marketo native field?

Highlighted
Level 10 - Community Moderator

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

That Program Form History is a Marketo native field?

No, that would be your history field that you append to whenever someone fills out a form. Imagine you concatenate with a semicolon.

Then in JS:

if ( "{{Lead.Program Form History}}".split(";").indexOf("{{Program.Id}}") == -1 ) {

  // lead hasn't filled out a form yet in this program 

}

Highlighted
Level 1

Re: Use REST API to identify if a Lead belongs to a Smart Campaign or Marketo Program

I agree with Sanford that you don't want to DoS yourself however if you have another use case that could benefit from a GetProgramsByLeadID endpoint I did add the idea to the Ideas forum here: and you could upvote it if you see fit.