Optimizely is the world’s leading experimentation platform, empowering marketing and product teams to test, learn and deploy winning digital experiences, every time.

It enables businesses to experiment deeply into their technology stack and broadly across the entire customer experience.

The integration of Optimizely with your Spree Commerce store can be done quickly and easily following the guidelines mentioned below.

The benefits of using Optimizely for your eCommerce business


A/B Testing

By comparing different versions of a webpage or app against each other, you can determine determine which one performs better.


Experience Optimization

In the offline world, an understanding of the customer comes naturally, but slowly—you learn a customer’s preferences over repeat visits, pick up on their habits, make assumptions about their demeanor based on initial interactions.


In the online world, customers are almost anonymous at the start of an engagement with a business. Savvy experience optimizers capitalize on the opportunity to deliver relevant, targeted experience to their customers based on who they are and what they do. Not only does this ensure the best possible experience for individual customers, but it enables delivery of a targeted and personalized experience at scale.



Optimizely helps you deliver targeted experiences to different visitors based on their behaviors, in real time. You can use Personalization to create a visitor experience that feels unique and highly relevant, increase conversions, and drive engagement.


Conversion Rate Optimization

Conversion rate optimization is important because it allows you to lower your customer acquisition costs by getting more value from the visitors and users you already have. By optimizing your conversion rate you can increase revenue per visitor, acquire more customers, and grow your business.

How to integrate Optimizely with Spree


Good news! If you are using Spree Commerce to power your e-commerce site, implementing the Optimizely snippet is incredibly easy. Here is an example of how to add the snippet to the <head> tag across your site.


Spree uses a tool called deface, which allows users to create override files that manipulate the HTML that is generated. Simply create a file in app/overrides/ of the store application with the following:


Deface::Override.new(:virtual_path => “spree/shared/_head”,

:name => “add_optimizely_to_header”,

:insert_after => “title”,

:text => ‘<script src=”//cdn.optimizely.com/js/12343566.js”></script>’)


Another way is to use Spree Analytics Trackers.

This extensions adds support for Google Analytics Enhanced Ecommerce and Segment Ecommerce tracking to Spree Commerce stores.


Via Segment.com you can plug-in also a lot of additional vendors and services like:



No additional development required.



  1. Add this extension to your Gemfile with this line:
gem 'spree_analytics_trackers', github: 'spree-contrib/spree_analytics_trackers'

  1. Install the gem using Bundler:
bundle install
  1. Copy & run migrations
bundle exec rails g spree_analytics_trackers:install
  1. Restart your server

If your server was running, restart it so that it can find the assets properly.


Adding specialized analytics to your online store has never been so simple! Just install `spree_analytics_trackers`, configure Segment and connect hundreds of various analytic solutions. – Piotr Leniec, Senior Fullstack Developer, Spark Solutions


Example of Optimizely and Spree integration


Finery London is an online womenswear brand with a unique point of view and a mission to make modern, inspiring and sophisticated styling accessible, without compromising on quality. The company uses Spree for its modern and elegant eCommerce platform and Optimizely for website optimization.

Read more: Finery London Success Story


Contact us

Learn more about Spree or start a new project!