Ecommerce Cart Segmentation

1. When should I use ecommerce cart segmentation?

When you want to display your message based on the contents of cart. For instance, when you want to provide a special offer to visitors who have added some products to their cart and a different message to visitors who haven’t put anything into their cart yet.

2. Why should I use ecommerce cart segmentation?

Cart abandonment is one of the main challenges for ecommerce sites. Using ecommerce cart segmentation with OptiMonk helps you keep your visitors moving towards checkout and encourages visitors to add items to their cart by displaying specific messages to each group of visitors.

3. How do I setup my site for OptiMonk to retrieve the contents of a visitor’s cart?

OptiMonk retrieves information on cart contents using JavaScript code. You customize the code based on cart contents, or specific items, then place that code on your site.

4. What code do I need for OptiMonk to retrieve information on cart contents?

When someone adds a product to their cart on your site, a code such as the one below should be executed:

<script type="text/javascript">
    var OptiMonkOnReady = function () {
        var adapter = OptiMonk.Visitor.createAdapter();
        adapter.Cart.add('product1', {quantity:3, price:1000});

PLEASE NOTE: OptiMonk.Visitor exists only if there is at least one active campaign on the domain.

In the above example OptiMonk only retrieves some very basic data about cart contents.

OptiMonk can also retrieve more detailed information about particular products in a visitor’s cart. For more detailed information, a code such as this should be executed:

<script type="text/javascript">
    var OptiMonkOnReady = function () {
        var adapter = OptiMonk.Visitor.createAdapter();
        adapter.Cart.add('product1', {quantity:3, price:1000, color:'blue' });
        adapter.Cart.add('product2', {quantity:2, price:1000, color:'red' });

In the above example two products added to cart are defined, their IDs are:

  • "product1" and "product2"

and, there are 3 unique variables passed for both products

  • quantity, i.e. – "3"
  • price, i.e. – "1000"
  • color, i.e. – "blue"

PLEASE NOTE: The quantity and price of the product are required data, so they should always be setup.

5. What happens when a visitor removes an item from their cart?

You can also add code to your site so OptiMonk knows when a visitor removes an item from their cart. To retrieve information when someone removes an item from their cart, use code such as this:

<script type="text/javascript">
    var OptiMonkOnReady = function () {
         var adapter = OptiMonk.Visitor.createAdapter();

Or you can empty the cart with a single call:

<script type="text/javascript">
    var OptiMonkOnReady = function () {
        var adapter = OptiMonk.Visitor.createAdapter();

6. Details to pay attention for when you insert the code

  • The name of your custom variables or products cannot include special characters
  • Products and variables are case sensitive
  • The OptiMonkOnReady function should be defined only once, i.e. - only one time per page.

7. How do I setup my OptiMonk campaigns to use the cart contents?

  1. Login to your OptiMonk account and go to the “Campaign Settings” page for the Campaign you want to use with your custom variables.
  2. Find the option for: “Visitors with specific cart content”. Here is where you can setup rules based on the content of the cart.

You can set up rules based on:

  • Cart value
  • The number or products added to cart
  • The number of product types added to cart

The following 5 parameters should be set up for rules applied to products in cart:

  1. The product(s) that should be used for the rule: all items, at least one of the items, none of the items.
  2. The name of the custom product variable.
  3. The type of value: text or number.
  4. The method of comparison: equals, doesn’t equal, contains, doesn’t contain, is set, isn’t set, greater than, less than, greater than or equal to, less than or equal to.
  5. Which value it should be compared to.

For at least one of the items in cart: The value of color variable, which is a text, equals blue

Have more questions? Submit a request