Rich-text Reply

Integrating with ASP.NET MVC

bill_sorensen 02-03-15
Accepted Solution

Integrating with ASP.NET MVC

Hi, I'm new to Optimizely and am trying to return a different view from my ASP.NET MVC controller based on the variation. I think I've figured out a solution, but it's (a) difficult to maintain and (b) difficult to test.

 

Basically I plan to:

 

-read the optimizelyBuckets cookie

-parse the JSON

-retrieve the property matching my experiment ID (from the diagnostic report)

-compare that against the variation IDs (from the diagnostic report)

-return a different view based on the variation

 

Is there a cleaner way? Thank you!

Junan 02-11-15
 

Re: Integrating with ASP.NET MVC

Hi @bill_sorensen 

 

I think you've pretty much got the idea of what you need to do. One thing that might help you build this in a more scaleable way, would be to use Optimizely's REST API (http://developers.optimizely.com/rest/) so you can pull down the list of experiment and variation IDs (or names). 

 

Hope that helps, let me know if you run into any issues!

Junan Pang
Optimizely

Re: Integrating with ASP.NET MVC

Thanks Junan, I missed that!

Re: Integrating with ASP.NET MVC

I'm not seeing what I need in the REST API.

 

In JavaScript, it's easy to find out which variation the current visitor sees:

 

http://stackoverflow.com/questions/17326157/optimizely-get-the-variation-of-the-current-visitor

 

Is this even possible through REST?

 

Thank you!

Junan 02-11-15
 

Re: Integrating with ASP.NET MVC

Hey @bill_sorensen 

 

No, sorry, you're right. You will need to use the JavaScript API (or the Optimizely Buckets cookie) to pull the current variation of the visitor. You can use the REST API to pull the entire list of experiments and their associated variations. This suggestion was more for the future when you would potentially be running many of these experiments and may want a table to refer to so you don't have to go to the Diagnostic Report every time to look up the information.

 

Hope that helps,

Junan 

Junan Pang
Optimizely