- Connect the Optimizely Visitor ID to a Lead or Contact
- Attach the Optimizely Visitor ID to a Hidden Field
- Grant Access to and Map the Visitor ID Field
- Configure Experiment History
- Send a Conversion Event to Optimizely
- Create a Custom Event in Optimizely
- View and Create Experiments
- View Results
- Reports and Dashboards
- Batch Updates
- Error Logging
- Validate Data and Attribution App Setup Success
- Configure the Data and Attribution for Salesforce app
Once installed and configured, the Optimizely Data and Attribution for Salesforce app (DNA) runs in the background on its own. If you’ve already followed the installation instructions, then you’re ready to begin the configuration process:
Connect Optimizely experiment visitor IDs to Salesforce records. This will be completed by your marketing operations team.
Display the experiment history custom lightning component for leads and contacts. This will be completed by a Salesforce admin.
Send a conversion event to Optimizely, map fields, and schedule data updates. This will be completed by a Salesforce system admin and an Optimizely admin.
The rest of this article describes these steps in detail. If you have any questions along the way, please contact your Optimizely support contact or file a support ticket.
Before you can follow these steps, you will first have to install and authenticate the DNA app.
Connect the Optimizely Visitor ID to a Lead or Contact
The Optimizely DNA managed package includes a new field, Visitor_ID, on lead and contact records.
You’ll need to pass the visitor ID to Salesforce in order to sync experiment data to the correct Salesforce record. If you’re using a marketing automation service like Marketo or Pardot to manage leads, you can create a hidden field to capture the Optimizely visitor ID and pass it to Salesforce.
Attach the Optimizely Visitor ID to a Hidden Field
Below are instructions for passing the visitor ID to Salesforce using common marketing operations solutions.
You can pass this field to Salesforce without these tools by using a CSV upload or any other marketing automation product that serves the purpose of passing data from a web form to Salesforce records. Additionally, there are Salesforce APIs that allow record updates. If you're not sure which option is best, please contact the Optimizely support team.
Visitor ID cannot include the following characters: $ # %
Marketo makes it easy to add a hidden field without any code. Here’s the full Marketo hidden field guide, and here are the steps you’ll need to take:
Log into your Marketo account and open the form where the field will be added.
Add a hidden field to the form.
Update the settings as follows:
Default Value: leave blank
Get Value From: select Cookie Value from the drop-down menu.
Parameter Name: set as optimizelyEndUserId (Important: be sure to use this exact parameter name including capitalization as shown).
Salesforce Pardot Users
Pardot allows you to pass data as a hidden field. The details depend on how your page and form are configured. Learn more by clicking here to visit the Pardot hidden field guide.
Grant Access to and Map the Visitor ID Field
Completing this part of configuration will ensure important events — e.g. a Lead converts to an Opportunity — are sent to Optimizely, giving your team accurate experiment results.
Grant Access Rights to Visitor ID Field
First, you will select which users should have access to the visitor ID field. Ensuring proper access will enable the visitor ID field to be successfully passed between Salesforce records.
Open Salesforce Setup
Search for and open “Object Manager”
Open “Lead” in the Object Manager view, and click “Fields & Relationships”
Click “visitor ID”, then click “Field-Level Security”
Assign read or write access to Profiles (e.g. click the check box under the “Visible” column for “Standard Users”)
Repeat this process for the “Contact” and “Opportunity” Objects
Map Visitor ID Field
Next, you will map “visitor ID” between Leads, Contacts, and Opportunities.
Open Salesforce Setup
Search for and open “Object Manager”
Select "Lead", click “Fields & Relationships”, then click "Map Lead Fields"
In the Custom Fields view, click the “Contact” tab, navigate to “Visitor Id”, click the adjacent picklist under the “Account Fields” column, and change the value from “None” to “visitor Id”
Click the “Opportunity” tab and repeat steps 4 and 5
To learn more about mapping custom fields, please visit this Salesforce guide.
Configure Experiment History
Once you establish a data connection with Optimizely and configure your visitor IDs, you can see the experiment history of Salesforce leads and contacts. Note, the experiment history component also works on for Case pages as long as the Case is tied to a Contact via the standard lookup.
The Experiment History view is a Salesforce Lightning component that shows key details about the experiment and variations that a given lead or contact has experienced. This custom Lightning component is created automatically when you install the DNA app.
Your Salesforce admin can visit the Lightning App Builder and edit the pages that should include the experiment history list.
To include the experiment history list for a given lead or contact:
Open the lead or contact in the Lightning App Builder.
Click the gear icon in the top right and choose to edit the page.
Add Experiment History List.
Save the updated view and activate.
Here’s an example of what the experiment history custom component looks like in a contact record page within Salesforce:
Click the experiment name to view experiment details and the variation name to view variation details:
Users provisioned with the Experiment History permission set, along with app admins and app users, wilI be able to see the visitor ID record(s) associated with their leads and contacts.
Experiment History Data Updates
Schedule Apex Jobs to Update Data
Completing this step of configuration ensures your team has fresh experiment history data. Even if your team does not plan to display the Experiment History Lightning component to users, we recommend completing this configuration so that you can create valuable reports — for example, you can create a report that highlights the conversion rate from experimented leads to opportunities over time.
You can schedule Apex jobs via the Optimizely app installation and settings manager, or via Salesforce's standard Apex job scheduler.
Schedule Apex Jobs via Optimizely's App (Recommended)
Most teams will schedule Apex jobs related to this app via the "Schedule Jobs" tab during app installation. This is easier to configure and manage than using Salesforce's standard Apex job scheduler. To configure or modify Apex jobs using this easier method, please follow the instructions provided in the installation guide.
Schedule Apex Jobs via Salesforce's Standard Scheduler
This alternate approach can be more time consuming to implement and manage than using Optimizely's app installation and settings manager. For example, if you wanted to schedule an Apex job to run each hour of the day to update Lead data, you would need to schedule 24 separate jobs via Salesforce's Standard Scheduler. In contrast, with Optimizely's app, you can accomplish this same outcome in a few clicks.
However, Salesforce's standard scheduler can be a good solution if your team requires much more granular control. Below is a guide to taking this approach.
This configuration must be completed by a Salesforce System Admin to avoid data syncing issues within organizations that have multiple teams.
You will complete the following steps for each job you wish to run for both Leads and Contacts.
Open Salesforce Setup
Search for and open, “Apex Classes”
Click the “Schedule Apex” button under the header of the Apex Classes view
Add a Job Name, e.g. “Lead Experiment History Updates’”
Click the search icon adjacent to the Apex Class field, and then click “LeadExperimentHistoryBatch” in the window that appears
Select your desired frequency settings
This process will arrange for a data update for Leads once per day. Repeat this process and modify the Preferred Start Time if you would like to run more frequent updates.
Repeat this process to schedule updates for Contact History — to do so, select the Apex Class field, “ContactExperimentHistoryBatch” when completing step 5 above.
To learn more about scheduling Apex Jobs, please visit this Salesforce guide.
Additional Syncing Information
Each day, Optimizely runs a scheduled batch job to link the experiment history associated with specific visitor IDs to any leads or contacts where a visitor ID has been added since the last batch update. Experiment history will only be pulled into Salesforce when the experiment type is A/B, Feature, or Other.
If there is already applicable experiment data in Salesforce, a new lead or contact visitor ID variation record will be created using the data Salesforce collects from this batch job. Otherwise, Salesforce creates the appropriate records at the variations, experiments, and/or projects levels.
Salesforce will append visitor ID variations and associated bucketing/experimentation data to the lead or contact visitor ID over the course of the next seven days. This is to capture any additional experiment history accumulated to the visitor ID after the initial bucketing event/experiment history.
This bucketing/experiment history data information will not be brought into Salesforce real-time. Instead, it is collected by a scheduled batch job that runs no more than once per hour.
Send a Conversion Event to Optimizely
Imagine you want to experiment with different website signup forms. When a lead or contact reaches a critical milestone in Salesforce (e.g., Lead Status = “Working - Contacted”), this Optimizely event can now be transmitted to Optimizely through the Process Builder. This added information can bolster the value of Optimizely’s analytics, adding richness and nuance to your experimental results.
App admins can set the criteria used by the Process Builder and configure the immediate action to map to the appropriate Optimizely event.
You can use either Process Builder or native Apex code to communicate events to Optimizely, and we share how to configure each option below.
Option 1: Send Conversion Event Using Process Builder
Salesforce’s Process Builder is a tool for building “if-then” conditions that tell Salesforce when to send events to Optimizely, and what those events should be. For example, “If the status of a Salesforce lead associated with an Optimizely experiment changes to ‘Market Qualified Lead,’ then share this event with Optimizely.”
The DNA includes Process Builder templates that you can use to get started quickly.
To send a Salesforce event to Optimizely:
In Salesforce, navigate to Settings.
Use the Salesforce Quick Find feature to search for and open Process Builder.
Select one of the three Optimizely Process Builder templates in the Salesforce list of My Processes:
Clone the template you selected in step 3 above. Alternatively, you can use the template as the basis for a new process you build yourself.
In the process’ detail view, click the blue diamond to modify the process criteria in a way that maps placeholders (i.e., “Replace Me”) to your desired criteria (for example, ‘set the “Lead Status” Salesforce field to “Market Qualified Lead”’).
In other words, this step is where you define what must occur in order for Salesforce to pass an event to Optimizely.
To configure the Process Builder’s Immediate Action, click the icon directly below Immediate Actions in Salesforce to configure it. This will permit Salesforce to pass an event directly to Optimizely.
If you choose to build a separate process or add a new node to an existing process rather than use the template, be sure to select "Create a Record" as the Action Type. Doing so will ensure you can set the Record Type as "Conversion Event."
Populate the fields Event Id and Event Key. To do this, select the applicable experiment from within Optimizely.
Within the Optimizely Experiment view, click on API Names in the left-hand navigation.
Locate the desired event, and use the appropriate ID / API Name pairing. Remember, the API name is what you’ll put in the Event Key field in Salesforce.
In the Immediate Actions screen in the Process Builder, click Action under Immediate Actions. In the Create a Record fields on the right side of the screen, enter the event ID and the event key in the appropriate field.
Click Save in the bottom of the settings view.
Click Activate in the top right corner of the settings view.
Option 2: Send Conversion Event Using Apex Code
You can optionally use Apex to create the conversion event and publish to the event bus.
The DNA app has a Conversion Event platform event. The platform event/invocable methods are global, so this means that the methods are accessible to write an Apex class against outside the app.
Please reference our Process Builder configuration documentation above to understand the Parameters the platform event will need. The Conversion Event takes four parameters:
- Visitor ID --> Type (Text 255)
- Event ID --> Type (Text 255)
- Event Key --> Type (Text 64)
- Experiment ID --> Type (Text 255)
Here is example code:
optimizely_dna__Conversion_Event__e e = new optimizely_dna__Conversion_Event__e();
e.optimizely_dna__Visitor_Id__c = 'your-visitor-id';
e.optimizely_dna__Event_Id__c = 'custom event id';
e.optimizely_dna__Event_Key__c = 'custom_event_key';
EventBus.publish(e); // event bus also supports lists
This is just an example for creating a single conversion event. To bulkify your code, you would need to utilize a list.
Create a Custom Event in Optimizely
To create a custom event, you’ll need to either select an existing custom event, or create a new one tied to the Process Builder.
If the desired event doesn’t exist, click Create New Event, select Custom, and fill in the fields. The new event will appear in the event list, along with a unique ID. The event API name (aka Event Key) and event ID will be entered in Salesforce Process Builder.
View and Create Experiments
You can view and manage your experiments from within the Experiments tab in Optimizely.
After configuring the custom event (potential_revenue, aka “Opportunity Creation”) in both Optimizely and Salesforce Process Builder, set this event as the primary metric in a new experiment.
The metrics defined for a given experiment are accessible by clicking the experiment name in the experiment list, then clicking Metrics.
See experiment results by clicking Results on the left side of the experiment screen, or from within the experiment detail view.
Optimizely provides results for each variation and metric. Here is a sample of what the Results page might look like:
Reports and Dashboards
Your team can gain additional value from the DNA app by creating custom reports that build on the experiment data linked to your leads and contacts.
For example, you could create a report for the leads or contacts in your experiment campaigns and re-target those records via email, or upload them with a CSV or TSV file into your Dynamic Customer Profiles (DCP).
You could also create a dashboard detailing how experimentation affects the success of your lead and opportunity pipeline:
By default, 10 visitor ID records are included per batch update. Increasing this limit can reduce the volume of API calls and enable updates to run faster; however, increasing the limit may also result in exceeding Salesforce limits. Salesforce has a callout limit of 100. You can roughly calculate total callouts as follows:
The total callouts equals the sum of the following:
- # of visitor IDs in the batch (batch size)
- 1 callout for each active Project returned in the above
- 1 callout for each of the active Experiments and Campaigns across all Projects
- 1 additional callout for each active Campaign across all Projects
As an example, for 1 project with 15 campaigns and 15 experiments with batch size 10 you would see 56 callouts: 10 callouts to Optimizely's Attribution API + 1 callout to Optimizely's Project API + 30 callouts to Optimizely's Experiments API + 15 callouts to Optimizely's Campaigns API
If you exceed you exceed the Salesforce governor limit for API callouts, Salesforce will log an error in the standard Salesforce Apex Job screen with the text "too many callouts" (example below).
Modify Batch Update Size
- Open Salesforce Setup
- Search for and select "Custom Settings"
- Open "Optimizely Settings"
- Click the "Manage" button
- Click "Edit"
- Enter a new value in the Batch Size field
- Click Save
The Custom Logging feature is controlled by an administrator. Optimizely logs errors to a custom object via a platform event, and an administrator can enable or disable logging, and specify how many records are to be deleted.
By default Optimizely keeps the 1,000 most recent errors logged, and prunes errors in excess of this limit. To modify the max number of logs, navigate to Setup > Custom Metadata Types > LogScience. You can optionally disable pruning, or modify the max number of logs.
If you would like to disable app error logging, navigate to Setup > Custom Metadata Types > Manage LogScience records, and set the Enable Logging toggle to False.
Validate Data and Attribution App Setup Success
Below are options for validating that your setup of the DNA app is successful. Before proceeding with validation, please ensure you have followed all instructions in the DNA installation and configuration guide above. Also, we recommend creating an AA experiment tied to a website lead form to facilitate the validation steps below.
1. Validate one-time successful communication of record experiment history and Salesforce event communication
Approach: confirm that DNA communication works for a single lead
Part A: Confirm Record Update
- Submit a dummy lead through a web form where an Optimizely experiment is running, and where Visitor ID is configured to be passed to Salesforce upon lead form submission.
- Visit the Optimizely app in Salesforce, and open “Schedule Jobs” in the App setup (under the “Optimizely App” tab)
- Click “Run Now” under the jobs scheduler for Leads
- Open the Lead record associated with the dummy lead
- Ensure that the Experiment History Lightning Web Component has been added to Lead page layout — you can optionally arrange for this to only appear for yourself (an admin) for evaluation purposes.
- Confirm whether Experiment History includes a new line item for the dummy lead, representing that the dummy lead was bucketed into that experiment
- Click on the experiment in the list, and identify which Variation the lead experienced
Part B: Confirm Event Communication
- Visit your AA Experiment in your dashboard at Optimizely.com
- Confirm whether the count of lead submissions increases by 1 for the variation the lead experienced
2. Validate ongoing successful communication of experiment history from website forms to Salesforce records
Approach: confirm that the count of newly created Salesforce Leads that were bucketed into an experiment (assigned a Visitor ID) aligns with the count of lead submissions in the associated Optimizely experiment
Create an AA Experiment in Optimizely, or use an existing experiment, that tracks total lead submissions from a given web form
Create a Salesforce report for Experimented Leads
Ensure you can see a breakdown of Leads that have and have not been assigned a Visitor ID
If possible, also include a field indicating the source of the lead (e.g. Landing Page Lead Form).
Go to Setup and create a new Report Type for Optimizely objects
Create three reports:
Leads grouped by Variation Experiment Name
Leads grouped by Converted or Not by Experiment Name/Variation
Create a Dashboard and Assemble these three reports into a single dashboard showing the different metrics
Compare total experimented Leads in Salesforce with total lead submissions in Optimizely for a given time frame and ensure the totals are roughly similar.
3. Validate ongoing successful communication of Salesforce events to Optimizely
Approach: confirm that the count of Market Qualified Leads with a Visitor ID aligns with the count of MQLs communicated to Optimizely via Salesforce Process Builder
Create an AA Experiment in Optimizely, or use an existing experiment, that tracks total lead submissions from a given web form
Ensure that the experiment includes a metric tied to a custom event that will be linked to Salesforce Process Builder
Create a Salesforce report for experimented MQLS
Ensure you can see a breakdown of MQLs that have and have not been assigned a Visitor ID
To create reports, ensure that the steps above have been completed for a custom report type and report showing Leads experimentations
Clone that report but add a grouping for the field that indicates MQL or not (it’s different for each customer)
Clone that first report again and group by whether
Ensure Process Builder is properly configured to communicate with Optimizely when an experimented Lead converts to a MQL, and that a corresponding Optimizely custom event has been attached to an experiment for at least as long as the time frame you plan to use for the value comparison.
Compare total experimented MQLs in Salesforce with total MQLs reported in Optimizely for a given time frame and ensure the totals are roughly similar.