Try our conversational search powered by Generative AI!

A/B testing - How to know if page is showing test content



I have a requirement to identify if the page is showing the test content (to find if A/b testing is running for current page). So, is the a way like particular cookie or code snippet to identify? Expecting some good solution to do that. :)

Thanks is Advance.

Nov 11, 2019 15:00

You can inject the ITestDataCookieHelper, you can then use this to work out which version of the test you are in

var allActiveTests = _testDataCookieHelper.Service.GetTestDataFromCookies();
var activeTest = allActiveTests.FirstOrDefault(x => x.TestId == testId);
if (activeTest != null)
	switch (Model.ViewingVersion)
		case "Any":

		case "Control":


		case "Challenger":

Nov 11, 2019 15:31

Hi Praful

You could do something like this:

bool anyActiveTests = IMarketingTestingWebRepository.GetActiveTestsByOriginalItemId(myPage.ContentGUID, "en").Any();

It tells you whether the page has any active tests, but it doesn't tell you whether you are right now viewing the page as a test.

I don't know if that comes close enough for you. If not, you will have to dig deeper (looking at the cookies and stuff).

Nov 12, 2019 6:50

Hey Guys thanks for the response.

@Stefan Holm Olsen Your solution worked, the only issue were with "en", I got this error 

error CS1503: Argument 2: cannot convert from 'string' to 'System.Globalization.CultureInfo'

Even I got the hint and solved it. Actually I got the active test without passing that culture info (as I can ignore language based for my requirement).

Thanks for the solution.

Nov 12, 2019 16:19
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.