SOLVED

Re: override Marketo "unsubscribe" system flow action

Go to solution
Margaret_Duff
Level 1

Re: override Marketo "unsubscribe" system flow action

Hi Delwin Ng ! I am successfully using a campaign like this to resubscribe people. Thanks to you (and Marketo Support) for sharing this tip!

Now, I'm curious about managing more granular email preferences across duplicate records, since our current data management strategy requires some intentional duplicates. I know the durable unsubscribes process can find duplicate records and push updates from one record to the rest. But I haven't seen a way to do that for any attribute except the "unsubscribe" attribute. Is there a way have changes to an email subscription attribute automatically populate across duplicate records?

For example, if a user goes into my preference center and subscribes to my "Inbox0IsALie" email series, I'd like to have the "Subscription - Inbox0IsALie" attribute updated across any other duplicate records. Is that possible? Thanks!

SanfordWhiteman
Level 10 - Community Moderator

Re: override Marketo "unsubscribe" system flow action

You can only do this for custom fields via a webhook that in turn loops back and calls the REST API.

Margaret_Duff
Level 1

Re: override Marketo "unsubscribe" system flow action

Thanks, Sanford Whiteman! I'm new to this, but want to see if I can figure it out. I have been reading the Marketo/Salesforce webhook and API documentation and trying to poke around github and the interwebz for examples of something similar. Any chance you have seen or built something with a similar structure that I you recommend I look at to help wrap my brain around this? Or, any tips on where to look? Any suggestions would be absolutely appreciated!

SanfordWhiteman
Level 10 - Community Moderator

Re: override Marketo "unsubscribe" system flow action

The webhook implementation will always be language-specific so we'd have to know what language is most comfortable for you to work in.

As our webhook service uses standard JavaScript, the main routine looks like this (with a more exception handling in production):

FBHttp.fetch(mktoRESTIdentity)

.then((identResp) => identResp.json())

.then((identRespJ) => {

// get session access_token

commonHTTPHeaders = {

'Authorization' : `bearer ${identRespJ.access_token}`,

'Content-Type' : 'application/json;charset=UTF-8'

}

})

.then(() =>

// get all leads matching current lead's email (including current lead)

FBHttp.fetch(

`${mktoRESTLeadsByFilterBase}?filterValues=${webhookContext.leadEmail}&fields=${fieldsToSync}&filterType=Email`,

{

headers: commonHTTPHeaders

}

)

)

.then((getResp) => getResp.json())

.then((getRespJ) => {

// filter list of leads to (a) exclude current lead and (b) leave only interesting custom fields to sync

var matchedLeads = getRespJ.result,

thisLead = matchedLeads.find((lead) => lead.id == webhookContext.leadId ),

secondaryLeads = matchedLeads.filter((lead) => lead != thisLead ),

reservedFields = ["id","email"],

pushInput;

reservedFields.forEach((field) => delete thisLead[field] );

pushInput = secondaryLeads.map((secondaryLead) => Object.assign({}, secondaryLead, thisLead) );

return Object.assign(pushTemplate, { input : pushInput });

})

.then((pushReq) =>

// sync list of leads back to Mkto

FBHttp.fetch(

mktoRESTPushLead,

{

method: "POST",

headers: commonHTTPHeaders,

body: JSON.stringify(pushReq)

}

)

.then((pushResp) => pushResp.json())

);

Margaret_Duff
Level 1

Re: override Marketo "unsubscribe" system flow action

Thanks! Excited to take a closer look at this.