Category: Search Optimization AB Testing
This integration is only available for Web projects
What to expect
This integration will allow you to convert Algolia's result variants into Contentsquare dynamic variables, allowing you to segment and analyze users based on their search experiences. This integration is restricted to a single search index per project, and requires an implementation of the full Algolia library version 4+.
What we collect
Dynamic Variables
Key | Value | Data Type |
AB_AG_{Experiment ID} | {Variant Index Number} | Text |
AB_AG_{Experiment ID}
The dynamic variable's key is the experiment ID associated with the test, and the value is the index position of the variant (1 representing first variant, 2 representing the second, etc...). You can find these values in Algolia's AB test settings-
Implementation
Implementation Steps
The response object of search function should contain the AB Test ID and AB Test Variant ID values in it which we need.
For example:
const abTestID = res.abTestID;
const abTestVariantID = res.abTestVariantID;
Once you have those values, you simply need to push them back to the browser, unless they already exist in the browser from some other analytics configuration you have from before, and then dynamically add it to the following client side Javascript code:
Simply replace the 2 variables var campaignID and var variationID with the string values of the test:
/* *Name: Algolia CS Integration *Version: 3.0.0 */ var version = "3.0.0"; var tvp = "AB_AG_"; function csCallback(context) { if (!disableCallback) { CS_CONF.integrations = CS_CONF.integrations || []; CS_CONF.integrations.push("Algolia - " + version); } } var disableCallback = false; window._uxa = window._uxa || []; _uxa.push([ "afterPageView", function (context) { csCallback(context); }, ]); function sendToCS(csKey, csValue) { csKey = tvp + csKey; _uxa.push([ "trackDynamicVariable", { key: csKey, value: csValue, }, ]); } //Replace the 2 values below with the actual string values of the campaign var campaignID = [abTestID]; var variationID = [abTestVariantID]; sendToCS(campaignID.toString(), variationID.toString()); //Algolia CS Integration End
The Contentsquare tag will then automatically take care of the rest of the logic.
Verifying it works
You can use the chrome extension to check the results are sent to CS