Hi Team,
I have a smart campaign built on custom object fields, and the custom object is tied at the account level. As a result, whenever a lead is closed, the record syncs to all contacts in Marketo, which causes the email to trigger for every contact with a unique email address. I’m trying to find a way to prevent this behavior.
One option is to pass a flag from CRM to Marketo to identify the specific contact associated with the lead so the others dont get an email (as content is really specific to the contact our sales team had a discussion). However, I wanted to check if there’s another way to handle this without adding an extra CRM field.
Is there a way to match the custom object field (on the left) with a lead level token (on the right.. could be {{lead.contact}} ) so that it only qualifies the contact id related to that lead? Also open to any other possible approaches—looking forward to your guidance.
Please let me know if you need anything else.
Regards,
Akshat
Solved! Go to Solution.
Like so:
#set( $sortedList = $sorter.sort($SomeObject_cList,"updatedAt:desc") )
#set( $focusedObject = $sortedList[0] )
#if( !$focusedObject.someField.equals($lead.someRelatedField) )
#throw( "ObjectRelationshipError" )
#end
Where the #throw Velocimacro is defined:
#macro( throw $message )
#if( !$message.isEmpty() )
#evaluate( "${esc.h}set( ${message} )" )
#end
#end
@SanfordWhiteman Thanks for your feedback on this one .
Can you please guide me with the Velocity script or share an example that I can use for testing?
Also, if possible, could you show how the filter would look once the Velocity condition is added? i think the velocity token needs to be added into the email right to abort the send if they dont match?
Regards,
Akshat
Like so:
#set( $sortedList = $sorter.sort($SomeObject_cList,"updatedAt:desc") )
#set( $focusedObject = $sortedList[0] )
#if( !$focusedObject.someField.equals($lead.someRelatedField) )
#throw( "ObjectRelationshipError" )
#end
Where the #throw Velocimacro is defined:
#macro( throw $message )
#if( !$message.isEmpty() )
#evaluate( "${esc.h}set( ${message} )" )
#end
#end
Thanks for sharing those scripts — really appreciate it.
I just wanted to validate my understanding and clarify a few points based on the testing i performed. I’ve broken them down question-wise below for clarity
1. Velocity Script Implementation
Based on my understanding, I added the Velocity scripts in the My Tokens section as separate tokens, and then referenced those tokens within the email body.
Could you please confirm if this is the correct approach?
2. Preview Testing Behavior
I tested a couple of examples using the email preview, and everything seemed to work as expected:
It throws an error for contact IDs that should not receive the email.
It previews successfully when the lead/contact ID matches the custom object contact ID.
If there are two leads in Marketo associated with the same account and they share the same email address, using that email as a sample in Preview only shows one record.
Is there a way to preview or filter both leads individually, or is the only option to send test emails to each lead separately to validate the behavior?
Can you confirm please?
3. Activity Logging for Excluded records
My next question is around activity logging.
When we send a test email and Marketo excludes a record from the send, does it still log an activity (for example, an email soft bounce)?
I came across this article while researching and wanted to confirm my understanding:
https://blog.teknkl.com/velocity-poison-pill-throw-error-revisited
Is there a way to avoid that activity logging, or would you recommend a different approach altogether?
Regards,
Akshat
1. Velocity Script Implementation
Based on my understanding, I added the Velocity scripts in the My Tokens section as separate tokens, and then referenced those tokens within the email body.
Could you please confirm if this is the correct approach?
Yes.
2. Preview Testing Behavior
Is there a way to preview or filter both leads individually, or is the only option to send test emails to each lead separately to validate the behavior?
Can you confirm please?
Create a static list with both leads and use Preview-by-List.
3. Activity Logging for Excluded records
My next question is around activity logging.
When we send a test email and Marketo excludes a record from the send, does it still log an activity (for example, an email soft bounce)?I came across this article while researching and wanted to confirm my understanding:
https://blog.teknkl.com/velocity-poison-pill-throw-error-revisitedIs there a way to avoid that activity logging, or would you recommend a different approach altogether?
You will see a Soft Bounce. You can’t avoid it.
Thanks @SanfordWhiteman This is really helpful and your feedback is really appreciated ..thanks alot once again !!
Regards,
Akshat
You’re welcome!