This article is about Optimizely X. If you're using Optimizely Classic, check this article out instead.
 
relevant products:
  • Optimizely X Web Experimentation
  • Optimizely X Web Personalization
  • Optimizely X Web Recommendations

this article will help you:
  • Use Lotame visitor data to create audiences in Optimizely
  • Integrate Lotame and Optimizely so that Lotame can pass information into experiments

Lotame is a Data Management Platform that provides demographic information about your visitors. This data allows you to define Optimizely custom attributes, which in turn allow you to analyze your results and target your experiments by otherwise unavailable attributes.

This article explains how to set up this integration.

Prerequisites

This integration requires a Lotame subscription and an Optimizely Enterprise account. Use Lotame's Audience Extraction API with Optimizely's JavaScript API to assign a visitor to a custom dimension when they're a member of a Lotame Audience.

Here's what you'll need:

  1. Your Lotame Client ID

  2. The Lotame Audience IDs of the audiences you'd like to use to create audiences in Optimizely

1. Create custom attributes in Optimizely

Here's how to create a custom attribute.

2. Deploy the integration snippet

In the following block of code, set the value of lotameId  (currently "12345") to match your Lotame Client ID.

 
Note:

The value of lotameId should be a string, not an integer.

Insert this code at the bottom of your head tag, wherever you wish to identify and segment your visitors. A standard implementation would deploy this site wide:

<script type="text/javascript">
window['optimizely'] = window['optimizely'] || [];
window['optimizely'].push({
  type: 'integration',
  OAuthClientId: '5395531275'
});
var lotameId = '12345'; // Replace with your Lotame Client ID

window.parseLotameAudiences = function(data) {
  var json = JSON.stringify(data, undefined, 2),
    obj = JSON && JSON.parse(json) || window.jQuery.parseJSON(json);

  var firstParty = obj.Profile.Audiences.Audience || [];
  var thirdParty = obj.Profile.Audiences.ThirdPartyAudience || [];
  var audiences = firstParty.concat(thirdParty);

  if (audiences) {
    window['optimizely'] = window['optimizely'] || [];
    for (var i = 0; i < audiences.length; i++) {
      var audienceId = audiences[i].id;
      if (audienceId) {

        optimizely.push(['setDimensionValue', lotameId, audienceId]);
        window['optimizely'].push(['trackEvent', window.location.href]);

      }
    }
  }
}

function getAudiences() {
  var url = 'http://ad.crwdcntrl.net/5/c=' + lotameId + '/pe=y/callback=parseLotameAudiences';
  var tempScriptTag = document.createElement('script');
  tempScriptTag.type = 'text/javascript';
  tempScriptTag.src = url;
  document.body.appendChild(tempScriptTag);
}

getAudiences();

</script>

Visitors bucketed into Lotame Audiences will now be included in the custom attributes on your Results page and through the targeting interface.

 
Tip:

Because the Lotame Audiences API is called asynchronously, after the Optimizely snippet, any segments a visitor is assigned will not be available until after the visitor's first pageview. This means you cannot use a segment defined by this integration to target an experiment until a visitor's second pageview.

The snippet described above could also be deployed by opening the Editor and pasting the code in the JavaScript text box. Just remember to delete the opening and closing script tags.