Skip to content
  • There are no suggestions because the search field is empty.

Integrate Convert Experiences with Amplitude

Track Convert Experiment Data in Amplitude for Deep User Insights & Analysis

Author:
Dionysia Kontotasiou

THIS ARTICLE WILL HELP YOU:



Convert-Amplitude Integration

Integration of Amplitude with Convert Experiences will help you to import Convert data into your Amplitude account. 

For each experiment, the integration can pass along the experiment name and variation name that the visitor is currently bucketed into (if any).

Add Tracking Code Snippets

Make sure the Convert tracking code is installed on your page.

Then, create an Amplitude account. If you have not already done so, go to https://amplitude.com and register for an account. Then, create an organization and a project. You will immediately receive an API Key for the project you have just created. On every page that you want to install Amplitude analytics, paste the code snippet just before the </head> tag.

Send Events

Add this code to Project > Configuration > Global Project Javascript to send the experience name and variation name to Amplitude. It works with the Amplitude Browser SDK 2 and with the older JavaScript SDK. It waits until Convert has evaluated the experiences on the page and Amplitude has loaded, then sends one event for each experience the visitor is in. When data anonymization is on in your project, it sends the experience and variation IDs instead of the names.

This code works with the current Convert tracking script. If your project still uses the Legacy tracking script, move to the current script first. For more on the window.convert object, see The window.convert Object in the developer docs.

window._conv_q = window._conv_q || [];
window._conv_q.push({
what: 'addListener',
params: {
event: 'snippet.goals_evaluated',
handler: function () {
var rows = getConvertData();
whenReady(function () { return window.amplitude && (amplitude.track || amplitude.getInstance); }, function () {
rows.forEach(function (row) {
var eventProperties = {
'Exp_Name': row.experienceName,
'Var_Name': row.variationName
};
if (amplitude.track) {
amplitude.track('Convert', eventProperties); // Browser SDK 2
} else {
amplitude.getInstance().logEvent('Convert', eventProperties); // older JavaScript SDK
}
});
});
}
}
});

// Returns the experiences the visitor is in on this page, with their variation.
// With data anonymization on, it uses IDs instead of names.
function getConvertData() {
var rows = [];
var current = convert.currentData.experiences || {};
var configured = convert.data.experiences || [];
var settings = convert.data.project && convert.data.project.settings;
var anonymize = !!(settings && settings.data_anonymization);
for (var experienceId in current) {
if (!current.hasOwnProperty(experienceId)) continue;
var variation = current[experienceId].variation || {};
var experience = configured.filter(function (e) {
return String(e.id) === String(experienceId);
})[0];
rows.push({
experienceId: experienceId,
variationId: String(variation.id),
experienceName: anonymize ? experienceId : (experience ? experience.name : experienceId),
variationName: anonymize ? String(variation.id) : variation.name
});
}
return rows;
}

// Waits up to 10 seconds for the tool's code to load, then sends the data.
function whenReady(isReady, send) {
var tries = 0;
(function check() {
if (isReady()) return send();
if (tries++ < 50) setTimeout(check, 200);
})();
}

View Convert Data in Amplitude

In order to see the data sent, you must login into your Amplitude account and create your own dashboard/chart based on the events you sent: