Sometimes the standard Campaign Influence models that come with Marketing Cloud Account Engagement (Pardot) just don’t quite fit what you are looking to measure. We recently went through the exercise of creating a Custom Model, and it wasn’t quite as straightforward as we would have liked it to be.
To save you some ramp-up time we’ve decided to share some of the things we learned. Here they are!
Lessons Learned the Hard Way while Creating a Custom Pardot Campaign Influence Model
We went ahead and created a custom Pardot Campaign Influence model and took excellent notes so you can reap all the benefits.
Here’s what you should know before you start your own custom Pardot Campaign Influence Model project.
Simplify your Custom Model, then nail it down
There’s a lot of calculations needed in Campaign Influence, and the last thing you want to do is build this a few times as you discover exactly what you are looking for.
Spend some time with the business and really think about which touches you really want to measure and if having them measured will drive meaningful business value. Can you explain it in 20 seconds or less? No? Your model might be too complex.
You have 2 options for integrating your Model
The simple example Salesforce provides as part of its documentation is to have a Trigger on the CampaignInfluence object, which allows you to create your records when Salesforce creates theirs. This example is okay for demonstrative purposes, and it avoids a lot of the complexities.
The example also works okay if the Model that you are “watching out for” creates and deletes CampaignInfluence records at the same time you need to. Though for us, often we discovered that we wanted our Model to recalculate, but it never did. This is because the default model didn’t need recalculating so no new records were created/edited. As a result, ours never had the chance to run.
One way around this is to watch out for the b2bmaEvenDistributionModel as it has the most chance of adding/removing records, and firing off your trigger.
Another thing to consider (if you are relying on another model’s calculation to trigger your custom one) is that Salesforce doesn’t properly batch influence calculation. We learned this when turning off the Even Distribution Model and turning it back on hoping it would trigger calculation on all Opportunities. We ended up having our own Batch APEX class run to initially populate data for our new model.
If you need a little more control, you would need to introduce triggers on various objects (such as CampaignMember, OpportunityContactRole, Opportunity) looking for the events that would have an impact on your Model and cause it to recalculate. You might find luck here using Platform Events to separate the triggering event from all the processing that the Model might need, especially important as Opportunities often already have a lot of custom automations hanging around them.
Campaign Influence code runs as a special User
Salesforce’s CampaignInfluence records are created by a Special Salesforce User “Salesforce Administrator” which you can’t pick when setting up debug logs. You can find this User’s ID by looking at the CreatedById field of any of the CampaignInfluence records in your org.
Setting up a Debug log for this user is a bit more involved than normal, and needs you to manually create a TraceFlag entry referencing the special User as well as the Id of DebugLevel. We used https://workbench.developerforce.com ‘s REST explorer to create the record, and we used the SFDC_DevConsole DebugLevel allowing us to use the DeveloperConsole to check out the logs as we were testing. A bit of setup for each debugging session, but worth it.
Break your code into debuggable chunks
We ran into a few different challenges as we were putting this together, and we found having our code broken up really sped up our debugging process. Each chunk of code had debug statements giving us an idea of the overall state / progress, which made it easy to quickly diagnose where things might be going awry.
While we aren’t yet ready to share a precise recipe, we can at least give you the ingredients we used!
- Build a list of Opportunity IDs of the Opportunities that need to be calculated
- Get all Opportunity details (including Opportunity Contact Roles)
- Get all needed CampaignMember records
- Calculate the “winning” CampaignMember records for each Opportunity
- Calculate the CampaignInfluence records needed from the “winning” CampaignMember records
- Insert final results
Plan for custom Campaign Influence Model success
Creating a Custom Campaign Influence Model is not for the faint of heart. It takes quite a bit of planning and work to put together even the simplest of Models (which might be why there’s so little out there when we tried googling for examples).
If you are looking to take this on, hopefully these tips save you a bit of frustration and colorful language. If it still looks daunting and you need some help, we would love to have a chat!
Further Reading
- Campaign Influence Starter Pack: The Easy Button to Prove Results from Pardot
- Connected Campaigns & Campaign Influence: How to Use Them to Get to the Metrics that Matter
- Secrets and Mysteries of Campaign Influence – ParDreamin’ 2021
- How to Show Marketing’s Influence on Pipeline with Salesforce Campaigns – ParDreamin’ 2020