Category: AB Testing
This integration is only available for Web projects
What to expect
With Dynamic Yield’s integration with Contentsquare, you can dive deeper into the main motivators driving visitor behavior on your digital properties. With Contentsquare’s Zone-based Heatmaps and Journey Analysis, you can further understand why every Dynamic Yield experience and variation performed as it did, how it impacted your customers’ journey, as well as provide additional insight on how to further iterate and update your personalization efforts for each customer segment. Leverage the Dynamic Yield & Contentsquare integration to:
- Access Zone-based Heatmaps to correctly attribute conversions and revenue to the successful elements of your personalization campaigns.
- Obtain proprietary behavioral metrics for every element on the page to cast light on the page’s average scroll reach and each element’s engagement levels.
- Use conversion funnels and Journey Analysis to understand how every experience impacted your customers’ journey across your digital properties.
What we collect
Dynamic Variables
Key | Value | Data Type |
AB_DY_{Campaign Name} | Variation : 1 | Text |
AB_DY_{Audience ID} | true | Text |
Implementation
Implementation Steps
There are 2 solutions to choose from. One is client side, the other is server side.
Please use the relevant section below.
Client Side Solution
Capturing Campaigns
Note that if you already had a previous version of the Contentsquare integration code installed then you will need to disable it, if not then skip this part.
To disable the old version, go to the Extensions tab and set Analytics Platform Integration to be inactive OR if you need some parts of that to run then edit it and remove the Contentsquare integration code from it.
Capturing Audiences
- Feel free to tweak the code as you need in terms of timing to make sure that the DY.ServerUtil.getUserAudiences function is available before the code runs. It is recommended to inject this code after Dynamic Yield.
- Please do not change the tvp variable though as this is a required prefix that needs to be the same as it is.
- The limit in the code is set to 20 and it is not recommended at all to increase that limit as there is a limit on how many dynamic variables can be sent to Contentsquare per pageview so you perhaps reach that limit faster if you have other integrations enabled that also use dynamic variables.
- It is recommended to tweak the code to allow allow certain Audience IDs to be sent to us, one's that you have interested in mainly. You can accomplish that by adding the Audience IDs to the allowList array in the code. You can find these IDs in the URL of your Dynamic Yield UI where you created the audiences.
Add them as comma separated numbers.
For example: var allowList = [1323949, 894638, 738182];
/* *Name: Dynamic Yield Audience ID CS Integration *Version: 1.0.0 */ var tvp = "AB_DY_"; function sendToCS(csKey, csValue) { csKey = tvp + csKey; _uxa.push([ "trackDynamicVariable", { key: csKey, value: csValue, }, ]); } var counter = 0; var limit = 20; //Add your Audience IDs to the array below with comma separated number values. You can find these values in the URL of your Dynamic Yield UI. var allowList = []; function csCallback() { if (!disableCallback) { disableCallback = true; setTimeout(function () { if (window.DY && DY.ServerUtil && typeof DY.ServerUtil.getUserAudiences === "function") { var getAudiences = DY.ServerUtil.getUserAudiences(); for (var i = 0; i < getAudiences.length; i++) { if (allowList.includes(getAudiences[i])) { var audienceID = "Audience ID : " + getAudiences[i]; var value = "true"; counter++; if (counter <= limit) { sendToCS(audienceID, value); } } } } }, 500); } } window._uxa = window._uxa || []; var disableCallback = false; _uxa.push(["afterPageView", csCallback]); // Dynamic Yield Audience ID CS Integration End
Server Side Solution
Add and tweak the following code in your web server's server side code which has the Dynamic Yield Server Side API response.
Note that in the code below the only part you need to tweak is where you see the [DY_RESPONSE_OBJECT] section which isn't a real object. This should be replace by the real object response that came back from Dynamic Yield's API. This code is all javascript and should be rendered in the server response back to your site on every pageview and for every test. Please do not tweak any other code logic above that.
/* *Name: Dynamic Yield CS Integration - Server Side *Version: 1.0.0 */ var version = "1.0.0"; var tvp = "AB_DY_SS_"; window._uxa = window._uxa || []; function sendToCS(csKey, csValue) { csKey = tvp + csKey; _uxa.push([ "trackDynamicVariable", { key: csKey, value: csValue, }, ]); } //Replace [DY_RESPONSE_OBJECT] with the actual response from DY which contains the required properties var choices = [DY_RESPONSE_OBJECT].choices; if (choices) { for (var i = 0; i < choices.length; i++) { var variations = choices[i].variations; var analyticsMetadata = variations[0] && variations[0].analyticsMetadata; if (analyticsMetadata) { var campaignName = analyticsMetadata.campaignName; var variationName = analyticsMetadata.variationName; if (campaignName && variationName) { sendToCS(campaignName, variationName); } } } } function callback() { if (!disableCallback) { disableCallback = true; if (window.CS_CONF) { CS_CONF.integrations = CS_CONF.integrations || []; CS_CONF.integrations.push("Dynamic Yield Server Side - v" + version); } } } var disableCallback = false; _uxa.push(["afterPageView", callback]); //Dynamic Yield CS Integration End
Verifying it works
You can use the chrome extension to check the results are sent to CS