Sha256: b7048e17b89d519772f37d0bbfdb7a7c64d9a9066ea3953e8c23e1aab2735656

Contents?: true

Size: 1.55 KB

Versions: 2

Compression:

Stored size: 1.55 KB

Contents

<% if order_just_completed?(@order) %>
  <script>
    if (typeof analytics !== 'undefined') {
      analytics.track('Order Completed', {
        order_id: '<%= @order.number %>',
        total: <%= @order.total %>,
        shipping: <%= @order.shipment_total %>,
        tax: <%= @order.additional_tax_total %>,
        discount: <%= @order.promo_total %>,
        coupon: '<%= @order.promo_code %>',
        currency: '<%= @order.currency %>',
        products: [
        <% @order.line_items.each do |line_item| %>
          {
            product_id: '<%= line_item.product.id %>',
            sku: '<%= line_item.variant.sku %>',
            name: '<%= line_item.product.name %>',
            price: <%= line_item.price %>,
            quantity: <%= line_item.quantity %>
          },
        <% end %>
        ]
      });

      analytics.page('Order Completed', {
        order_id: '<%= @order.number %>',
        total: <%= @order.total %>,
        shipping: <%= @order.shipment_total %>,
        tax: <%= @order.additional_tax_total %>,
        discount: <%= @order.promo_total %>,
        coupon: '<%= @order.promo_code %>',
        currency: '<%= @order.currency %>',
        products: [
        <% @order.line_items.each do |line_item| %>
          {
            product_id: '<%= line_item.product.id %>',
            sku: '<%= line_item.variant.sku %>',
            name: '<%= line_item.product.name %>',
            price: <%= line_item.price %>,
            quantity: <%= line_item.quantity %>
          },
        <% end %>
        ]
      });

    }
  </script>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_analytics_trackers-1.1.0 app/views/spree/shared/trackers/segment/_order_complete.js.erb
spree_analytics_trackers-1.0.1 app/views/spree/shared/trackers/segment/_order_complete.js.erb