Technical Guide
This page contains technical information for experienced Salesforce administrators who are looking for a deeper explanation of the key jobs that run as part of the Campaign Monitor for Salesforce application.
See: Troubleshooting guide
API usage
Salesforce has strict governor limits around the use of API calls. The Campaign Monitor for Salesforce application does not use any API calls when syncing.
There are two types of API calls, inbound and outbound. Outbound calls from Salesforce do not count against governor limits.
All syncing to and from Campaign Monitor are done via outbound calls. For example, if you are sending 100K emails to Campaign Monitor via any of our syncing methods i.e. subscriber rules, import wizard, list views etc, they will not count against your salesforce API limit.
The only time the Campaign Monitor for Salesforce application uses inbound API calls is when you:
a) Use a Salesforce list view to perform a bulk operation. For example if you select add contacts to a subscriber list when working from a list view or via the import wizard. This will use up just 1 inbound API call.
b) Navigate to the sync settings page. This will use up just 1 inbound API call.
In general, you should not need to worry about the Campaign Monitor application using up your inbound API limits.
Custom Objects
When the installation has been completed, the Salesforce objects below will be created in your Salesforce Org. These objects contain either records or settings required for our application to work. Our product has been designed to be self-contained, not to impact standard objects.
- Campaign Monitor clients
- Campaign Monitor campaigns
- Subscriber lists
- Subscriber list members
- Email tracking history
- Automatic subscriptions
- Custom field mappings
- Smart emails
- Smart email mappings
- Smart email variables
Our object structure should not be customized as it may stop our application from working correctly or stop automated upgrades.
Campaign Monitor tab
When clicking on the Campaign Monitor tab within Salesforce, you may be redirected to a new browser tab. This will open with a direct login to Campaign Monitor.
- Users will be automatically logged into Campaign Monitor using the Campaign Monitor user ID associated with their Salesforce account. See: Permissions
- The Campaign Monitor menu in the new tab can be toggled on and off. To enable the Campaign Monitor menu, navigate to Campaign Monitor admin, general and enable the setting Show tabs on the Campaign Monitor layout in Salesforce
- The new tab is required due to the enforcement of SameSite settings. See: link
If the tab does not open check your browser settings as the popup might be blocked. See: Block or allow pop-ups in Chrome
Background jobs
The list below are the batch jobs that can run in the background within Salesforce.
CMBatchCampaign
Pulls in email history from Campaign Monitor into Salesforce. The records are stored in email tracking history (wbsendit__Campaign_Activity__c). This table may contain a large number of rows. See: Storage. This job runs as part of the primary sync between Salesforce and Campaign Monitor.
CMBatchCampaignStats
Updates any linked Salesforce campaigns with statistics from the related Campaign Monitor campaign (i.e. number of clicks, bounces, unsubscribed etc). This job optionally runs as part of the primary sync between Salesforce and Campaign Monitor. It runs if the following setting is set to active update Salesforce campaign statistics with Campaign Monitor statistics. See: Manage campaign settings.
CMBatchDeleteSubscribers
Runs as part of the import wizard job if the replace subscribers on list option is enabled under advanced settings. It removes any subscribers from Campaign Monitor that were not in the import wizard report or list view. If there are a large number of subscribers to remove from Campaign Monitor, this job can take a long time to complete. If this is the case, you could also consider creating a completely separate subscriber list for the import and deleting the old list - as this could be more efficient.
CMBatchJourneyStats
CMBatchJourneyStats is responsible for updating the object Journey_Email__c, which contains stats about the journey. This information is largely only visible via Salesforce reporting.
Journey_Email__c.Bounced__c
Journey_Email__c.Clicked__c
Journey_Email__c.Email_Id__c
Journey_Email__c.Journey__c
Journey_Email__c.Opened__c
Journey_Email__c.Sent__c
Journey_Email__c.Unique_Opened__c
Journey_Email__c.Unsubscribed__c
After that job has run, we then run CMBatchJourney. This collects the individual email tracking records and stores it in Campaign_Activity__c - this is the object we store standard email tracking data and is then displayed against the Lead/Contact related list (email activity etc) and also on the email activity component.
CMBatchEmailOptOut
This batch updates the standard Salesforce email opt-out field on the contact and lead records based on the subscriber status. It will opt out any subscribers that are unsubscribed from all subscriber lists within Campaign Monitor. This job optionally runs as part of the primary sync between Salesforce and Campaign Monitor. It runs when the following setting, in the General Settings, Options is enabled: Set email opt to true when a contact or lead is unsubscribed or deleted in all lists and a contact or lead is unsubscribed or deleted in all lists.
CMBatchSubscriber
Updates Salesforce with the status of any subscribers it finds in Campaign Monitor. If the create rule is enabled it may create and link new subscribers as contacts or leads in Salesforce along with any mapped fields. This job runs as part of the primary sync between Salesforce and Campaign Monitor. If it is unable to update Salesforce, due to restricted fields etc, then a message will be logged under maintenance messages.
CMBatchSuppression
The CMBatchSuppression batch job will iterate through all CM clients and make a callout to get emails on the suppression list. The results are stored within the Suppression__c object. It will remove any emails from the Suppression__c object where they have been removed from the suppression list in CM.The CMBatchSuppression batch job is called in the finish method of the CMConfigBatch batch job. It runs in parallel to other primary sync jobs and has no downstream jobs (i.e. it's largely independant).
CMBatchSubscriberStats
Updates Salesforce subscriber lists with statistics from the related Campaign Monitor subscriber list (i.e. number of clicks, bounces, unsubscribed etc). This job runs as part of the primary sync between Salesforce and Campaign Monitor.
CMConfigBatch
Syncs Campaign Monitor configuration data with Salesforce. This includes syncing any Campaign Monitor lists, clients and users with Salesforce. For example, if a user has created a list directly in Campaign Monitor, then this job needs to have run before it will appear in Salesforce. This job runs as part of the primary sync between Salesforce and Campaign Monitor.
CMScheduleSubscribers
This is a schedulable job that is called from sendItScheduleSubscriptions when the sync is enabled. It starts the primary sync between Salesforce and Campaign Monitor.
ImportListViewBatch
Calls from the import wizard, emails from a Salesforce list view into Campaign Monitor. The process runs under the scheduled user and as such will only have access to the Salesforce records that user can see.
ImportScheduler
A scheduler for running import wizard jobs. It runs hourly under the Salesforce user who requested the scheduled import jobs. This is to ensure the import wizard runs under the owner of the person who started the job (and therefore can only see records available to them).
ProcessAsyncRecords
This is a queueable job that runs if it needs to send Salesforce data to Campaign Monitor (typically for a single CRUD operation on an account, lead or contact). It can be invoked from a trigger or process builder action.
It will typically only run if there are a) any mapped fields for the subscriber list that the contact or lead is associated with, or b) if there are automatic subscription rules that meet the criteria for a contact or lead, c) there is an email change on the contact or lead.
You can prevent the ProcessAsyncRecords from being called by setting, disable Salesforce account, contact and lead triggers to active under sync settings.
ProcessAsyncRecordsBatch
This is a batch job that runs if it needs to send Salesforce data to Campaign Monitor. It is similar to ProcessAsyncRecords in that it can be invoked under the same conditions. The difference is that it will run when there are multiple records that need to be processed. It works by processing items held in a custom object called Queue_Item__c. It will continue to process these records in atomic transactions. If there are still more items to be processed in the Queue_Item__c object when the batch job completes, it will re-spawn itself.
N.B. If you are running multiple Salesforce process flows that update the same Salesforce object, this can result in multiple ProcessAsyncRecordsBatch jobs running at the same time. To reduce the chance of this happening, where possible, structure your Salesforce process flows to update the same Salesforce object.
You can reduce the number of ProcessAsyncRecordsBatch being run by setting, disable bulk triggers for account, contact and lead triggers' to Active under sync settings. This will result in only the first record in a transaction being processed.
RefreshCampaignHistory
Manages the space used by the email tracking history object. See: Storage. This job can take a long time to run if a full re-import of Campaign Monitor data into Salesforce has been requested. See: Maintenance
RefreshSubscribers
Clears out the subscriber list member (wbsendit__Subscription__c) object. It’s called when a full refresh is requested a full re-import of Campaign Monitor data into Salesforce. See: Maintenance
ReportToListBatch
Called as part of the import wizard, this imports subscriber details from a Salesforce report into Campaign Monitor. It can run as a one off manually initiated job or via a scheduled process (if the user has configured this via the import wizard).
SmartEmailBatch
Updates Salesforce with smart email template details fetched from Campaign Monitor. This job runs as part of the primary sync between Salesforce and Campaign Monitor. See: Transactional
SmartEmailDetailsBatch
Updates Salesforce with smart email template variable details fetched from Campaign Monitor. This job runs as part of the primary sync between Salesforce and Campaign Monitor.
SmartEmailTaskDetailsBatch
Updates tasks in Salesforce that were sent as part of a smart email. It pulls in the actual text that was sent to the subscriber. This job runs as part of the primary sync between Salesforce and Campaign Monitor.
Process Builder Invokable Action
The Salesforce process builder is a powerful tool and when combined with Campaign Monitor for Salesforce, it provides fine grain control over sending targeted transactional emails to subscribers.
The trade off comes with the complexity of setting up and debugging processes. To help troubleshooting emails that are not sending, you can test the last step in the process builder action with the code below (i.e. try running the code in the Salesforce developer console). This is essentially the code that is called when you use the smart email invokable action in the process builder. If the code below works, then any problems are likely to be related to the fact that the invokable action is not being triggered i.e. a status on a field used in your Salesforce process builder logic may not be correct etc.
You can also test your Salesforce process by creating a dummy task or updating a value on an object. The code below will help check if the correct ID's were used in the smart email invokable action in the process builder.
There are two main variables you need to find and use:
RootObject (record ID) - This is the ID of the Salesforce record i.e. contact ID, lead ID etc.
Smart email mapping ID - This is the ID found on the smart email mapping record.
When selecting the object to base the process on in the Process Builder, avoid checking "Recursion - allow process to evaluate a record multiple times in a single transaction?" - this can cause issues with Salesforce governance limits, as the action may be called multiple times.
Salesforce domain name
The Salesforce process builder is a powerful tool and when combined with Campaign Monitor for Salesforce, it provides fine grain control over sending targeted transactional emails to subscribers.
If you are using Salesforce Lightning but don't have a Domain set up, you may receive the error similar to this: No CONTROLLER named js://wbsendit.pagination found
Salesforce requires a domain to be set up in order to use Lightning components, which are used as part of the Campaign Monitor for Salesforce application. See Enable my domain to use lightning components
Setting up a Salesforce domain will remove this message.
This Video walks you through setting up a Domain Name.
Sandboxes
You can install our integration in one or more sandboxes. You can also refresh a sandbox and our application will be copied across below is some more detailed information.
How to install in a sandbox
Go to our Salesforce AppExchange listing.
Click the Get it now button.
If you are not already logged in you will be prompted to do so.
Choose Sandbox.
Select I have read and agree to the terms and conditions, then click Confirm and Install.
Choose whether to install for admins only, all users or specific profiles. We recommend you select Admins only and once installed give users access via our permission sets.
Click Install.
Select Yes, grant access to these third-party websites then click Continue.
Sandbox refresh
When you start a sandbox refresh a copy of your installed applications will also be copied. This will include Campaign Monitor for Salesforce and there are some important points below to consider.
- When strongley recommend not to connect any sandbox to your live Campaign Monitor account.
- When a sandbox refresh happens we use a standard Salesforce process to disconnect Campaign Monitor from Salesforce.
- You can also manually run a process before or after the sandbox refresh to clear out connection settings.
- When refreshing either a full or partial sandbox data from our objects can be copied from production.
We don't recommend connecting a sandbox to your live Campaign Monitor account. Changes made in a sandbox can incorrectly update your Campaign Monitor data.
Sandbox conflicts
As mentioned above when refreshing a Salesforce sandbox, there may be some settings carried across from production. It is worth noting we do have some code that runs as part of the refresh to avoid this. But in very rare scenarios, the code can be conflicted with. So to help we have two options to return settings to their default state.
1. Before starting the sandbox refresh
When refreshing the Salesforce sandbox, there is now an option to run a post-installation script. You can enter the value CMSandboxRefresh this will execute our code to clear out the settings.
2. After the sandbox has been refreshed
a. Open the Salesforce developer console (developer console-->debug-->open execute anonymous window).
b. Enter in wbsendit.SendItAPI.resetSettings();
c Press Execute, this will take a few seconds to execute.
Either option will reset the main settings, after performing these steps you will need to connect to Campaign Monitor.
How to test in a sandbox
When you have our product in a sandbox we recommend connecting it to a test Campaign Monitor account. The best way to setup a test account is to create a new Campaign Monitor account that is pay-as-you-go. This will allow you to test features in a dedicated account.
If you have questions on which Campaign Monitor account to setup please contact Campaign Monitor directly - help.campaignmonitor.com
Global APIs
Several APIs have are included in the Campaign Monitor for Salesforce package. These can be called via custom code. Please note that this is for advanced users only and any custom code related to these APIs will not be supported.
Update status of a Subscriber in Salesforce
Refresh the subscriber details from Campaign Monitor within Salesforce. E.g. updates the status, and custom field data without having to wait for the primary sync. The list Id can be found in Salesforce under Subscriber List --> Details --> System Information.
String email = 'foo.bar@example.com';
wbsendit.SendItAPI.importSubscriber(listId, email);
Create a Subscriber List
Create a Campaign Monitor subscriber list The client Id can be found on the detail page for Campaign Monitor Client (in Salesforce --> Sync Settings --> click on the Campaign Monitor Client name --> Campaign Monitor Client Id).
String listName = 'My List Name'; // Name of the list.
wbsendit.SendItAPI.createSubscriberList(clientId, listName);
Reset
Reset all Campaign Monitor for Salesforce configuration data. Typically used after refreshing a sandbox. This ensure no production data or configuration related details are stored (i.e. it will prevent accidental syncs with a production Campaign Monitor instance).
Set Bulk Action Behaviour
Set the behaviour of triggers within the Campaign Monitor for Salesforce package. All triggers can be disabled via using `ALL_ACTIONS` as the action type. This can be useful when bulk loading data and preventing the triggers from firing.
Boolean disableActions = true;
wbsendit.SendItAPI.setBulkActions(actionType, disableActions);
Clear Campaign History
This will remove all tracking data from Salesforce. It does not remove the data from Campaign Monitor.
Integer batchSize = 1000;
wbsendit.SendItAPI.clearCampaignHistory(deleteFrom, batchSize);
Uninstall Package
This will uninstall the Campaign Monitor for Salesforce package. This removes page layouts, configuration etc. This can be useful when clearing out test environments.
Delete Process
When a bulk request is made to the transactional emails, a hidden variable is set to track the request against a user (it's used for performance reasons). This API will remove all hidden process records.
wbsendit.SendItAPI.deleteProcesses(delCount);
Uninstall Process
If you need to uninstall our product it is worth noting your Campaign Monitor data will remain safe in you Campaign Monitor. Specifically your subscriber lists, members, campaigns, templates, email tracking, etc...
When the uninstall process completes our package, its custom objects and the data contained within them will be removed. Any standard Salesforce records like accounts, contacts, leads, campaigns or campaign members created by our integration will remain.
We have built a fully automated uninstall process. However, it is possible that this flow may not work, particularly if our application has been customized or it runs into a conflict. If this happens there are manual steps below.
To start the automated process click one of the buttons below depending on what type of Salesforce environment you are working with.
Manual uninstall process
There are two dependencies you need to remove, page layouts and permission sets. Start by removing page layouts.
In Salesforce go to the Campaign Monitor admin app.
Click on the General settings tab.
Select the Maintenance option.
From here click Remove layouts.
Next you need to remove users from our two permission sets.
In Salesforce go to the Campaign Monitor admin app.
Click on the General settings tab.
Then select User security.
Search and select for the user(s) you want to assign the permission set to.
Click the Edit permissions button.
Select the None and click Assign permission set.
Finally with all dependencies removed you can now uninstall the package.
Click Setup.
In the Quick Search type installed.
Next to Campaign Monitor for Salesforce, click Uninstall.
Choose whether or not to save a copy of the package's data.
Select Yes, I want to uninstall this package and permanently delete all associated components.
Click Uninstall.
The uninstall process takes some time, once completed you will receive an email from Salesforce.