Integrate Salesforce: Configure the Data and Attribution App

  • Updated
  • Optimizely Web Experimentation
  • Optimizely Performance Edge
  • Optimizely Full Stack (Legacy)

Configure the Data and Attribution for Salesforce app

Before you follow these steps, you first have to install and authenticate the DNA app. Once installed and configured, the Optimizely Web Experimentation Data and Attribution for Salesforce app (DNA) runs in the background on its own. After you install DNA, configure it with the following process:

  1. The Marketing operations team connects Optimizely Web Experimentation experiment visitor IDs to Salesforce records.

  2. A Salesforce administrator displays the experiment history custom lightning component for leads and contacts.

  3. A Salesforce system admin and an Optimizely Web Experimentation admin sends a conversion event to Optimizely Web Experimentation, map fields, and schedule data updates.

Contact Optimizely Support if you have any questions or file a support ticket.

Connect the visitor ID to a Lead or Contact

The Optimizely Web Experimentation DNA-managed package includes a new field, visitor_ID, on lead and contact records.

You need to pass the visitor ID to Salesforce to synchronize experiment data to the correct Salesforce record. If you use a marketing automation service like Marketo or Pardot to manage leads, you can create a hidden field to capture the Optimizely Web Experimentation visitor ID and pass it to Salesforce.

Attach the visitor ID to a hidden field

You can upload a hidden field with a CSV file or other marketing product that passes data from a web form to Salesforce records. You also can use Salesforce APIs to update records. Contact Optimizely support for advice on your best approach,

Visitor ID cannot include the following characters: $ # %

Adobe Marketo

Marketo adds a hidden field without any code. See Set a Hidden Form Field in Marketeto documentation,  and here are the steps you’ll need to take:

  1. Log into your Marketo account and open the form where the field will be added.
  2. Add a hidden field to the form.
  3. 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.
      This is case sensitive so you must enter it exactly as it is written above.
  4. Click Save.


Salesforce Pardot users

Pardot lets you pass data as a hidden field. The details depend on how your page and form are configured. See Passing Hidden Fields to Account Engagement Forms in Salesforce documentation. 

Oracle Eloqua users

Eloqua supports hidden fields as a custom form element. See Contact fields, form elements, and field groups and Capturing submission data from external forms in Oracle documentation. 

Grant access to the visitor ID field

Select the users you want to have access to the visitor ID field. Proper access passes visitor ID field among Salesforce records.

  1. Open Salesforce Setup.
  2. Search for and open Object Manager.
  3. Open Lead in the Object Manager view, and click Fields & Relationships.
  4. Click visitor ID, then click Field-Level Security.
  5. Assign read or write access to Profiles by selecting boxes in the Visible column for Standard Users.
  6. Repeat this process for the Contact and Opportunity Objects.

Map visitor ID

Map visitor ID among Leads, Contacts, and Opportunities.

  1. Open Salesforce Setup.
  2. Search for and open Object Manager.
  3. Select Lead, click Fields & Relationships, then click Map Lead Fields.
  4. In the Custom Fields view, click the Contact tab, go to Visitor Id, click the adjacent picklist under the Account Fields column, and change the value from None to visitor Id.
  5. Click Save.

  6. Click the Opportunity tab and repeat steps 4 and 5.

See Guidelines for Mapping Custom Lead Fields for Lead Conversion in Salesforce documentation. 

Configure experiment history

When you establish a data connection with Optimizely Web Experimentation and configure your visitor IDs, you can see the experiment history of Salesforce leads and contacts. The experiment history component also works on for Case pages if 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 lead or contact:

  1. Open the lead or contact in the Lightning App Builder.
  2. Click the gear icon in the top right and choose to edit the page.
  3. Add Experiment History List.
  4. 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:

experiment history top level view.png

Click the experiment name to view experiment details and the variation name to view variation details:

experiment drilldown view.png

Users provisioned with the Experiment History permission set, along with app admins and app users, will be able to see the visitor ID record(s) associated with their leads and contacts.

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 Web Experimentation app installation and settings manager, or via Salesforce's standard Apex job scheduler.

Schedule Apex jobs via Optimizely Web Experimentation'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 Web Experimentation'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 Web Experimentation'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 have to complete the following steps for each job you wish to run for both Leads and Contacts.

  1. Open Salesforce Setup.
  2. Search for and open, Apex Classes.
  3. Click the Schedule Apex button under the header of the Apex Classes view.
  4. Add a Job Name, e.g. Lead Experiment History Updates.
  5. Click the search icon adjacent to the Apex Class field, and then click LeadExperimentHistoryBatch in the window that display.
  6. Select your desired frequency settings.
  7. Click Save.

This process will arrange for a data update for Leads once per day. Repeat this process and modify the Preferred Start Time if you want 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 Web Experimentation 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 only once per hour.

Send a conversion event to Optimizely Web Experimentation

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 Web Experimentation event can now be transmitted to Optimizely Web Experimentation through the Process Builder. This added information can bolster the value of Optimizely Web Experimentation'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 Web Experimentation event. 

You can use either Process Builder or native Apex code to communicate events to Optimizely Web Experimentation, 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 Web Experimentation, and what those events should be. For example, “If the status of a Salesforce lead associated with an Optimizely Web Experimentation experiment changes to ‘Market Qualified Lead,’ then share this event with Optimizely Web Experimentation.” 

The DNA includes Process Builder templates that you can use to get started quickly. 

To send a Salesforce event to Optimizely Web Experimentation:

  1. In Salesforce, navigate to Settings
  2. Use the Salesforce Quick Find feature to search for and open Process Builder.
  3. Select one of the three Optimizely Web Experimentation Process Builder templates in the Salesforce list of My Processes:
    • Contact Conversion
    • Lead Conversion
    • Opportunity Conversion
  4. 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.
  5. 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 Web Experimentation.
  6. Click Save.
  7. 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 Web Experimentation. 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.  
  8. Populate the fields Event Id and Event Key. To do this, select the applicable experiment from within Optimizely Web Experimentation. 
  9. Within the Optimizely Web Experimentation Experiment view, click on API Names in the left-hand navigation.
  10. 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. 
  11. 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.
  12. Click Save at the bottom of the settings view.
  13. 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 it 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:

  1. Visitor ID – Type (Text 255)
  2. Event ID – Type (Text 255)
  3. Event Key – Type (Text 64)
  4. 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 of creating a single conversion event. To bulk up your code, you would need to utilize a list.

Create a Custom Event

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 does not exist, click Create New Event, select Custom, and fill in the fields. The new event displays 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 Web Experimentation.


After configuring the custom event (potential_revenue, aka “Opportunity Creation”) in both Optimizely Web Experimentation 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.


View Results

View experiment results by clicking Results on the right side of the Experiments screen:


Or from within the experiment detail view:


Optimizely Web Experimentation provides results for each variation and metric. Here is an example of what the Campaign 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:

report image.png

Batch updates

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 equal the sum of the following:

  1. # of visitor IDs in the batch (batch size).
  2. 1 callout for each active Project returned in the above.
  3. 1 callout for each of the active Experiments and Campaigns across all Projects.
  4. 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 Web Experimentation's Attribution API, 1 callout to Optimizely Web Experimentation's Project API, 30 callouts to Optimizely Web Experimentation's Experiments API, and 15 callouts to Optimizely Web Experimentation'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).

too many callouts

Modify Batch Update Size

  1. Open Salesforce Setup
  2. Search for and select Custom Settings
  3. Open Optimizely Settings
  4. Click the Manage button
  5. Click Edit
  6. Enter a new value in the Batch Size field
  7. Click Save

Error Logging

The Custom Logging feature is controlled by an administrator. Optimizely Web Experimentation 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 Web Experimentation 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

  1. Submit a dummy lead through a web form where an Optimizely Web Experimentation experiment is running, and where Visitor ID is configured to be passed to Salesforce upon lead form submission.
  2. Visit the Optimizely Web Experimentation app in Salesforce, and open Schedule Jobs in the App setup (under the Optimizely App tab).
  3. Click Run Now under the jobs scheduler for Leads.
  4. Open the Lead record associated with the dummy lead.
  5. Ensure that the Experiment History Lightning Web Component has been added to the Lead page layout — you can optionally arrange for this to only appear for yourself (an admin) for evaluation purposes.
  6. Confirm whether Experiment History includes a new line item for the dummy lead, representing that the dummy lead was bucketed into that experiment.
  7. Click on the experiment in the list, and identify which Variation the lead experienced.

Part B: Confirm Event Communication

  1. Visit your AA Experiment in your dashboard at 
  2. 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 Web Experimentation experiment

  1. Create an AA Experiment in Optimizely Web Experimentation, or use an existing experiment, that tracks total lead submissions from a given webform.
  2. Create a Salesforce report for Experimented Leads
    1. Ensure you can see a breakdown of Leads that have and have not been assigned a Visitor ID
    2. If possible, also include a field indicating the source of the lead (for example, Landing Page Lead Form).
    3. Go to Setup and create a new Report Type for Optimizely Web Experimentation objects
    4. Create three reports:
      1. Leads grouped by Variation Experiment Name
      2. Leads grouped by Converted or Not by Experiment Name/Variation
    5. Create a Dashboard and assemble these three reports into a single dashboard showing the different metrics.
  3. Compare total experimented Leads in Salesforce with total lead submissions in Optimizely Web Experimentation for a given time frame and ensure the totals are roughly similar.

3. Validate ongoing successful communication of Salesforce events to Optimizely Web Experimentation

Approach: confirm that the count of Market Qualified Leads with a Visitor ID aligns with the count of MQLs communicated to Optimizely Web Experimentation via Salesforce Process Builder

  1. Create an AA Experiment in Optimizely Web Experimentation, or use an existing experiment, that tracks total lead submissions from a given webform. Ensure that the experiment includes a metric tied to a custom event that will be linked to Salesforce Process Builder.
  2. 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
      1. Clone that report but add a grouping for the field that indicates MQL if applicable for your customer.
      2. Clone that first report again and group by whether
  3. Ensure Process Builder is properly configured to communicate with Optimizely Web Experimentation when an experimented Lead converts to a MQL, and that a corresponding Optimizely Web Experimentation 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.
  4. Compare total experimented MQLs in Salesforce with total MQLs reported in Optimizely Web Experimentation for a given time frame and ensure the totals are roughly similar.