Table of Contents
Overview
This integration combines Amplitude's analytics with Optimizely's experiment tools into one unified system. Using this integration will allow you to share all user data in real-time and allow non-technical product and marketing team members to do full-circle tracking, analysis, and engagement across web and mobile apps.
The integration will send Optimizely experiment data into Amplitude so you can make use of Optimizely's experimentation tools and Amplitude's array of charts to understand user behavior.
This integration is available to all customers who have access to Optimizely's Custom Analytics Integration feature.
About Optimizely
Optimizely allows you to create and run different experiments to help you optimize your user experiences.
How to Set up and Use the Integration
Important:
- Must have the most updated Amplitude JS SDK (version 4.7 or higher) implemented.
- The Amplitude JS SDK must be placed above the Optimizely snippet.
- Amplitude utilizes Optimizely's Custom Analytics Integration feature for setup.
- Log in to your Optimizely account, select the correct Optimizely project, and head to Settings --> Integrations. The URL should follow this path:
https://app.optimizely.com/v2/projects/[PROJECT_ID]/settings/integrations
- Select Create Analytics Integration.. --> Using JSON
- Insert the following code:
{
"plugin_type": "analytics_integration",
"name": "Amplitude Analytics Integration",
"form_schema": [
{
"default_value": "[Optimizely Experiment]",
"field_type": "text",
"name": "property_prefix",
"label": "User Property Prefix: A user property for your experiment will be sent in an identify call. The user property will be prefixed with this prefix.",
"options": null
},
{
"default_value": "n",
"field_type": "dropdown",
"name": "send_event",
"label": "Send Event: Optionally send an event with campaign, experiment, and variation info",
"options": {
"choices": [
{
"value": "n",
"label": "No (not needed)"
},
{
"value": "y",
"label": "Yes"
}
]
}
},
{
"default_value": "User in Experiment",
"field_type": "text",
"name": "event_name",
"label": "Event Name (optional)",
"options": null
},
{
"default_value": "",
"field_type": "text",
"name": "instance_name",
"label": "Instance Name (optional): The instance name you are using in your amplitude instrumentation eg: amplitude.getInstance('my instance name'). Usually this is blank.",
"options": null
}
],
"description": "Send an identify call to amplitude identifying the experiment variation the user is seeing. Also, optionally send an event to amplitude that the user is in an experiment.\n\nSettings:",
"options": {
"track_layer_decision": "// VERSION 0.1.0\n// Last Updated: July 9th 2019\n\nvar dataSent = false;\nvar MAX_ATTEMPTS = 9;\nvar RETRY_DELAY_MS = 1000;\n\nfunction getCampaignInfo() {\n return window.optimizely\n .get(\"state\")\n .getDecisionObject({ campaignId: campaignId });\n}\n\nfunction logEvent() {\n var campaignInfo = getCampaignInfo();\n\n if (campaignInfo) {\n var eventProperties = {\n \"[Optimizely Campaign]\": campaignInfo.campaign,\n \"[Optimizely Experiment]\": campaignInfo.experiment,\n \"[Optimizely Variation]\": campaignInfo.variation,\n \"[Optimizely Holdback]\": campaignInfo.holdback\n };\n amplitude.getInstance(extension.instance_name).logEvent(extension.event_name, eventProperties);\n }\n}\n\nfunction identifyCall() {\n var campaignInfo = getCampaignInfo();\n\n if (campaignInfo) {\n var identify = new amplitude.Identify().set(\n extension.property_prefix + \" \" + campaignInfo.experiment,\n campaignInfo.variation\n );\n amplitude.getInstance(extension.instance_name).identify(identify);\n }\n}\n\nfunction sendData() {\n if (!dataSent) {\n identifyCall();\n if (extension.send_event === \"y\") {\n logEvent();\n }\n }\n dataSent = true;\n}\n\nfunction sendToAmplitude(call) {\n if (call >= MAX_ATTEMPTS) {\n return;\n }\n \n var instanceKey = extension.instance_name || \"$default_instance\";\n\n if (window.amplitude && window.amplitude.getInstance) {\n var instance = window.amplitude.getInstance(extension.instance_name);\n \n if (instance._isInitialized) {\n return sendData();\n } else if (instance.onInit) {\n instance.onInit(function() {\n sendData();\n });\n return;\n }\n }\n \n return setTimeout(function() {\n sendToAmplitude(call + 1);\n }, RETRY_DELAY_MS);\n}\nsendToAmplitude(0);"
}
} - Turn the integration on within the Optimizely Project Settings page. It will be listed as Amplitude Analytics Integration.
- Navigate to an experiment that you'd like to turn the integration on for. In the Optimizely experiment settings panel, go to Integrations, enable Tracked for the Amplitude Analytics Integration, and hit Save.
- User Property Prefix: A user property will be sent to Amplitude to identify users who have been bucketed into this Optimizely experiment. This prefix setting makes it easier to identify said user properties in Amplitude.
- Send Event [Optional]: Optional setting to send an event every time an experiment is fired. Configure to either yes or no.
- Event Name [Optional]: If you've selected to send an event, in this setting you can name what event it is. Example: "Viewed Experiment"
- Instance Name [Optional]: Please refer to our JS SDK for more information about Amplitude Instance Names
- Once the Optimizely experiment is running and data is collected, the user properties for this experiment will appear in Amplitude.
As always, please don't hesitate to reach out to Amplitude Support by clicking the "Help" button for any questions you have.