Velocitip: Distinguish Alerts from real Emails — and a bit on Email to Salesforce

One of Marketo’s coolest features (or sub-features) is the ability to use the same email asset in both a Send Email step (sent to the real lead) and a Send Alert step (the personalized email content for that lead, but sent instead to someone else).

This feature is great for mirroring content to the lead owner so they’re ready for follow-up, or to another team member for proofing.

Problem is, if you send exactly the same content, it can be offputting unless the person is expecting such emails at all times of the day!

Luckily, Velocity knows the difference. The reference $mktmail.SP_Send_Alert_Info is a non-empty String if it’s an Alert. Otherwise it’s a regular Email.

So just put a token like this up top (or another unobtrusive place):

#if( !$mktmail.SP_Send_Alert_Info.isEmpty() )
<span>You’re being copied on this email to ${lead.Email}</span>
#end

A more complex use case was brought up by local NYC MUG user AR last week:

Some of my sales reps asked if the triggered Marketo emails that look like they come from the sales reps could BCC their “Email to Salesforce” email so it creates an activity on the lead record. I tried using Send Alert, but it didn’t work as the email wasn’t sent to that specific person so Salesforce didn’t know what to do.

If you’re not familiar with Email to Salesforce (E2S) it’s a cool way to relate outbound emails to SFDC Leads/Contacts/Opportunities. Note it’s not made for high-volume batch blasts. Rather, it’s for person-to-person emails — or, as in this case, low-volume simulated person-to-person emails sent via Marketo triggers.

E2S works by processing inbound email and looking for one of 2 things:

  1. SFDC Lead/Contact records whose Email Address matches the To: and/or Cc: headers of the email.
  2. SFDC Lead/Contact/Opportunity records whose Record ID (15-digit alphanumeric ID) matches a value you explicitly add to the email Subject: line or body, prepended by the string ref:. For example, you could add ref: 701D0000000HQZy to the end of the subject line, or to the very end of the body where it wouldn’t disrupt the rest of the layout.

Now, the reason a simple Send Alert doesn’t work with approach (1) above is that the Alert is sent To: the Alert recipient you choose in Marketo (i.e. the E2S address), so the original Lead/Contact’s email doesn’t appear in the headers.

(For example, if I send an Alert to emailtosalesforce@825610a3bdd440ac83d9.salesforce.com in the context of the Marketo lead sandy@teknkl.com, the email content will be the same content sandy@teknkl.com would receive, but the To: will read emailtosalesforce@825610a3bdd440ac83d9.salesforce.com. Thus the intended SFDC lead/contact sandy@teknkl.com isn’t in the headers.)

But we can still use approach (2)! Just need to know when we’re sending an email as a Send Alert step vs. as a Send Email step. If it’s an Alert, we add the special ref: line.

So, as a framework, we need something like this:

#if( !$mktmail.SP_Send_Alert_Info.isEmpty() )
ref: the-SFDC-Record-ID-goes-here
#end

Ah, but we’re not quite out of the woods.

I used the placeholder the-SFDC-Record-ID-goes-here because there isn’t a built-in Velocity-accessible Marketo field that corresponds to the SFDC Id. Yes, there’s {{lead.SFDC Id}}, but that’s exclusively a {{lead.token}}; there isn’t a corresponding $lead.SFDCId in Velocity. (Strange, I know, but it’s presumably because the field is a “lead_function” field in Marketo, sort of a meta-field as it needs to encompass both Lead ID and Contact ID.)

However, we can create a custom String field and keep it up to date with an operational Smart Campaign that uses Change Date Value to set our new field to {{lead.SFDC Contact ID}} if present, or to {{lead.SFDC Lead Id}} if the Contact ID is empty.

2020-09-04-03_45_58-Marketo-_-TEKNKL-Test-Leads---Database2020-09-04-03_47_22-Marketo-_-TEKNKL-Test-Leads---Database

You might already have such a “mirror field” (it comes in handy). Another way to maintain it is of course on the Salesforce side.