Sha256: ca27f7db33085c99214f92bf46d4fa4b592f8bb01027ec04f87f59b726fba8ba

Contents?: true

Size: 1.96 KB

Versions: 5

Compression:

Stored size: 1.96 KB

Contents

<% if tracker = current_tracker %>
  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', '<%= tracker.analytics_id %>', 'auto');
    ga('require', 'displayfeatures');
    ga('send', 'pageview');

    <% if @order && order_just_completed?(@order) %>
      <%# more info: https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce %>
      ga('require', 'ecommerce', 'ecommerce.js');
      ga('ecommerce:addTransaction', {
        'id': '<%= j @order.number %>',                                    // Transaction ID. Required.
        'affiliation': '<%= @order.store.name %>',                 // Affiliation or store name.
        'revenue': '<%= @order.total %>',                                // Grand Total.
        'shipping': '<%= @order.ship_total %>',                                  // Shipping.
        'tax': '<%= @order.tax_total %>',                                        // Tax.
        'currency': '<%= @order.currency %>'                        // local currency code.
      });
      <% @order.line_items.each do |line_item| %>
        ga('ecommerce:addItem', {
          'id': '<%= j @order.number %>',                        // Transaction ID. Required.
          'name': '<%= j line_item.variant.product.name %>',    // Product name. Required.
          'sku': '<%= j (line_item.variant.sku || line_item.variant_id) %>', // SKU/code.
          'category': '',                                     // Category or variation.
          'price': '<%= line_item.price %>',                 // Unit price.
          'quantity': '<%= line_item.quantity %>'           // Quantity.
        });
      <% end %>
      ga('ecommerce:send');
    <% end %>
  </script>
<% end %>

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_multi_domain-1.5.0 app/views/spree/shared/_google_analytics.html.erb
solidus_multi_domain-1.4.3 app/views/spree/shared/_google_analytics.html.erb
solidus_multi_domain-1.4.2 app/views/spree/shared/_google_analytics.html.erb
solidus_multi_domain-1.4.1 app/views/spree/shared/_google_analytics.html.erb
solidus_multi_domain-1.4.0 app/views/spree/shared/_google_analytics.html.erb