Categories

Getting Started

Learn through 101 guides and easy solutions.

Creating a Custom Pardot Campaign Influence Model: Lessons Learned

Creating a Custom Pardot Campaign Influence Model: Lessons Learned

min. reading

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!

  1. Build a list of Opportunity IDs of the Opportunities that need to be calculated
  2. Get all Opportunity details (including Opportunity Contact Roles)
  3. Get all needed CampaignMember records
  4. Calculate the “winning” CampaignMember records for each Opportunity
  5. Calculate the CampaignInfluence records needed from the “winning” CampaignMember records
  6. 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

Subscribe to The Spot

Hidden
Hidden
Hidden
Hidden
This field is for validation purposes and should be left unchanged.

Community Events

Categories

Top 10 Recent Post

  • Adam Erstelle is a Developer with Sercante. He loves learning about and solving really interesting challenges with Pardot and Salesforce often by building some cool tools.

Leave Your Comment

Related Articles

Bot Single Post