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.
- Would what I'm describing above actually work, therefore I'm doing something wrong?
- Is there a better method of accomplishing what I'm trying to do?
Check this thread: https://community.optimizely.com/t5/Developers/Boo
Change it from running an alert to setting the value of your form's input field.
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:
And the results from those 3 selected options would look like this:
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.
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:
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!
UI Developer @ Blue Acorn