Sha256: cad63a559caff7f87fed27a09d1951f036aafa17db3f6dc29bcb6b1b2d853fd0

Contents?: true

Size: 845 Bytes

Versions: 2

Compression:

Stored size: 845 Bytes

Contents

<% if segment_enabled? && @order.present? && !@order.complete? %>
  <script>
    window.addEventListener('turbolinks:load', function() {
      if (typeof analytics !== 'undefined') {
        var segmentCartJson = {
          cart_id: '<%= @order.number %>',
          products: [
            <% @order.line_items.each_with_index do |line_item, index| %>
              <%=
                product_for_segment(
                  line_item.product,
                  position: index+1,
                  quantity: line_item.quantity,
                  image: default_image_for_product_or_variant(line_item.variant)
                )
              %>,
            <% end %>
          ]
        }

        analytics.track('Cart Viewed', segmentCartJson);
        analytics.page('Cart Viewed', segmentCartJson);
      }
    });
  </script>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_analytics_trackers-2.1.1 app/views/spree/shared/trackers/segment/_cart_viewed.js.erb
spree_analytics_trackers-2.1.0 app/views/spree/shared/trackers/segment/_cart_viewed.js.erb