Rich-text Reply

Track Which Optimizely Variation is Running and Feed Into Web Form Submission?

stebesplace 12-17-15

Track Which Optimizely Variation is Running and Feed Into Web Form Submission?

I tried looking into reading the optimizelyBuckets cookie to pull a relevant ID for which variation of an experiment a visitors is seeing, and then push that value into a hidden field which is submitted when a user completes a form (which then is sent to Salesforce). This way, I'd be able to attribute a sale back to a specific variation (test).

 

When I view the optimizelyBuckets cookie, I see a bunch of JSON values, that all have a shelf life of 10 years, so there's a lot of data in there already from various experiments I'm assuming.

 

Two questions:

  1. Would what I'm describing above actually work, therefore I'm doing something wrong?
  2. Is there a better method of accomplishing what I'm trying to do?

 

 

JDahlinANF 12-17-15
 

Re: Track Which Optimizely Variation is Running and Feed Into Web Form Submission?

try this:

Check this thread:  https://community.optimizely.com/t5/Developers/Bookmarklets/m-p/13006#M865

 

The first bookmarklet is one I wrote that does a javascript alert with a list of the names of any Experiments and Variations running on the current page.

 

Change it from running an alert to setting the value of your form's input field.

 

Re: Track Which Optimizely Variation is Running and Feed Into Web Form Submission?

Hey @stebesplace,

 

I wrote a bookmarklet a ways back that gives you access to all sorts of information about any site/page running Optimizely, leveraging the Optimizely JavaScript API.

 

You can determine what active experiments are running, what variations you're mapped to (name/index/ID), the account ID, project ID, etc.  It's all presented in a GUI modal interface. You can see a screenshot of the options offered here:

 

http://screencast.com/t/aPqZoKS7sSS

 

And the results from those 3 selected options would look like this:

 

http://screencast.com/t/tP0oayWcLzA

 

 

To use this, simply bookmark any page. Then paste the code from the following Gist into the URL/URI field for the bookmark (namely, where the web address would be) and sive it. After that, you can then click on this bookmark while browsing any site to run it. If Optimizely is not loaded on the page, it will throw an alert indicating such and exit the rest of the code.

 

Gist itself: https://gist.github.com/seanemmel-ba/0c2679ea3dcebfe7e560

Raw code: https://gist.githubusercontent.com/seanemmel-ba/0c2679ea3dcebfe7e560/raw/fccad9e1b0a5bfb996dfe645894...

 

 

With regard to what you're trying to do, you can leverage the Optly JS API and use the variationIdsMap or the variationNamesMap properties of the optimizely global JS object to read out the values it seems you're looking for. For example, here's me logging these values to the browser console on this page right now:

 

http://screencast.com/t/clOpol90akh7

 

 

So if you're wanting to use the variation ID, then definitely use the optimizely.variationIdsMap property and target the experiment ID of the exp in question. Then you can submit that via the hidden input/field you mentioned. Hopefully this helps!

 

-- Sean
UI Developer @ Blue Acorn

optimizely developer certification