AB Tasty

AB Tasty enables clients to build end-to-end experiences that drive growth across all digital channels. Marketing, product and engineering teams work together to deliver seamless user experiences with the help of AB Tasty.

To sync AB Tasty with your FullStory account, follow these instructions.

  1. In your FullStory Account, go to Settings > FullStory Setup and copy your data capture snippet 
  2. In your AB Tasty Account, go to Account Management > Account JavaScript and paste the FullStory data capture snippet in the code editor.
  3. Copy the custom integration script (found at the bottom of this page) and paste it below the data capture snippet in the code editor.
    AB_Tasty_Screenshot.png
  4. Click on Save to deploy the integration across all of your AB Tasty enabled pages.

Once the instructions above have been completed, AB Tasty will start to send the campaign’s name and ID, as well as the variation’s name and ID to FullStory as a custom event. These custom events will be sent at each page load. It will also work if the visitor is exposed to more than one campaign. For example, if a visitor is exposed to 3 experiments on a page, then we will send 3 custom events.

Please Note: If you added the FullStory data capture snippet using a tag manager or your CMS, you only need to add the custom integration script in the code editor.

In your FullStory account, navigate to Segments > New Segment. Then, choose Custom Events under Event Filters and find/select ABTasty Experiment.

If you want to filter sessions on a given experiment, use the attributes campaign_name or campaign_id. To filter on variation, use variation_name and variation_id.

Please Note: On AB Tasty, the original variation (control group) always has 0 for its variation ID.

In session playback, you can see the detail of the AB Tasty experiment data in the event log sidebar.

Custom Integration Script

// AB TASTY CONFIGURATION CODE
(function() {
	const sendMasterOnMP = false;
	const cleverForPerso = false;
	const listenLaterCampaigns = true;
	const sendBySession = false;
	var isFSReady = false; window['_fs_ready'] = function() {
		isFSReady = true;
	};
	function waitTool() {
		return isFSReady;
	}

// campaignInfos construction example: {testID: THE_TEST_ID, testName: THE_TEST_NAME, variationID: THE_VARIATION_ID, variationName: THE_VARIATION_NAME}
  
	function sendEvent(campaignID, campaignInfos, isLastCampaign) {
    const FSEventPayload = {
      campaign_id_int: campaignInfos.testID,
			campaign_name_str: campaignInfos.testName,
			variation_id_int: campaignInfos.variationID,
			variation_name_str: campaignInfos.variationName
		};
		FS.event('ABTasty Experiment', FSEventPayload, 'ABTasty');
		return true;
  }

// *DON’T CHANGE THE CODE BELOW*

  function waitData(condition, callback) {
    condition() ? callback() : setTimeout(function() {
      waitData(condition, callback);
		}, 500);
	}
	function start() {
  	const AB = window.ABTasty;
		const isTagV3 = function() {
      return typeof AB.getAccountSettings === "function";
    };
		const getAccountSettings = isTagV3() ? AB.getAccountSettings : function() {
      return AB.accountSettings;
		};
		const getParentDatas = function(id) {
			return isTagV3() ? AB.accountData.tests[id] : AB.tests.filter(function(el) {
        return el.datas.id == id;
			})[0].datas;
		};
		const getParentId = function(campaignDatas) {
			return isTagV3() ? campaignDatas.parentID : campaignDatas.masterTest;
		};
		function getABTastyCookie() {
			const abCookieDatas = getAccountSettings().storageMode == "local" ? ["ABTasty", localStorage.getItem("ABTasty")] : document.cookie.match(/.*ABTasty=([^;]+).*/);
			if(abCookieDatas && abCookieDatas[1]) {
				const abCookie = JSON.parse('{"' + decodeURIComponent(abCookieDatas[1]).replace(/&/g, '","').replace(/=/g, '":"') + '"}');
				abCookie.th = abCookie.th.split("_").map(function(el) {
					return el.split(".");
				});
				return abCookie;
			}
			return null;
		}
		let isNewSession = false;
		if(!isTagV3()) {
			const sessionNumber = getABTastyCookie().ns;
			const navigationDatas = JSON.parse(localStorage.getItem("ABTastyData"));
			isNewSession = navigationDatas["VisitedPages"] ? navigationDatas["VisitedPages"].filter(function(el) {
				return el.visite == sessionNumber;
			}).length < 2 : true;
		} else {
			const abTastySessionCookie = new HELPERS.ABTastySessionCookie();
			isNewSession = abTastySessionCookie.isNewSession;
		}
		let alreadyTreat = [];
		const alreadySend = !isNewSession && localStorage.getItem("ab_campaignsAlreadySend") ? localStorage.getItem("ab_campaignsAlreadySend").split(",") : [];
		let currentCampaigns = [];
		function getCampaignDatas(campaignID) {
			const campaignResults = AB.getTestsOnPage()[campaignID];
			const campaignDatas = campaignResults.testDatas;
			const parentDatas = getParentId(campaignDatas) !== 0 ? getParentDatas(getParentId(campaignDatas)) : null;
			const wantedDatas = {
				testID: Number(campaignID),
				testName: campaignResults.name,
				variationID: Number(campaignResults.variationID),
				variationName: campaignResults.variationName
			};
			if(parentDatas !== null && ((sendMasterOnMP && parentDatas.type === "multipage") || (cleverForPerso && parentDatas.type === "mastersegment"))) {
				wantedDatas.testID = Number(parentDatas.id);
				wantedDatas.testName = parentDatas.name;
				if(parentDatas.type === "multipage") {
					const masterVariation = Object.keys(parentDatas.variations).filter(function(el) {
            return(parentDatas.variations[el].name === campaignResults.variationName);
					});
					wantedDatas.variationID = masterVariation && masterVariation.length > 0 ? Number(parentDatas.variations[masterVariation[0]].id) : wantedDatas.variationID;
				} else {
					wantedDatas.variationID = Number(campaignID);
					wantedDatas.variationName = campaignResults.name;
				}
			}
			return wantedDatas;
		}
		function sendCurrentCampaigns() {
			currentCampaigns = currentCampaigns.concat(Object.keys(AB.getTestsOnPage()).filter(function(el) {
				return currentCampaigns.indexOf(el) < 0;
			}));
			currentCampaigns.forEach(function(el, index) {
				if(alreadyTreat.indexOf(String(el)) > -1) return;
				alreadyTreat.push(String(el));
				const datasToSend = getCampaignDatas(el);
				if(isNaN(datasToSend.variationID) || typeof datasToSend.variationName !== 'string') {
					alreadyTreat = alreadyTreat.filter(function(id) {
						return id !== el
					});
					Return;
				}
        if(alreadySend.indexOf(String(datasToSend.testID)) > -1) return;
				sendEvent(el, datasToSend, index == currentCampaigns.length - 1);
				alreadySend.push(String(datasToSend.testID));
				sendBySession && localStorage.setItem("ab_campaignsAlreadySend", alreadySend);
			});
			return true;
		}
		function hasPendingCampaigns() {
			return(Object.keys(AB.results).filter(function(el) {
				return AB.results[el].status === "pending";
			}).length > 0);
		}
		function sendNewCampaigns() {
			if(!listenLaterCampaigns) return true;
			if(hasPendingCampaigns()) {
				var waitNewCampaigns = setInterval(function() {
					sendCurrentCampaigns();
					if(!hasPendingCampaigns()) clearInterval(waitNewCampaigns);
				}, 800);
			}
			var oldABTastyStartTest = window.ABTastyStartTest;
			var newABTastyStartTest = function(testID, variationID) {
				oldABTastyStartTest(testID, variationID);
				sendCurrentCampaigns();
			};
			window.ABTastyStartTest = newABTastyStartTest;
			return true;
		}
		sendCurrentCampaigns() && sendNewCampaigns();
		const beforeResend = setInterval(sendCurrentCampaigns, 250);
		setTimeout(function() {
			clearInterval(beforeResend);
		}, 1500);
	}
	function waitToStart() {
		return(waitTool() && (typeof ABTasty !== "undefined" && typeof ABTasty.results !== "undefined" && (document.cookie.indexOf("ABTasty=") > -1 || localStorage.getItem("ABTasty") != null)));
	}
	waitData(waitToStart, start);
})();

// END AB TASTY INTEGRATION CODE

Need to get in touch with us?

The FullStory Team awaits your every question.

Ask the Community Technical Support