Sha256: c0efb8fcc49cb9b3c0de9c85bbff1f27ff7e15526bcfe9a9d6f85bbdeee8971d

Contents?: true

Size: 1.81 KB

Versions: 2

Compression:

Stored size: 1.81 KB

Contents

<% if tracker = Spree::Tracker.current %>

  <%= javascript_tag do %>
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', '<%= tracker.analytics_id %>']);
    _gaq.push(['_trackPageview']);

    <% if flash[:commerce_tracking] %>
      // report e-commerce transaction information when applicable
      _gaq.push(['_addTrans',
        "<%= @order.number %>",                            // Order Number
        "",                                                // Affiliation
        "<%= @order.total %>",                             // Order total
        "<%= @order.adjustments.tax.sum(:amount) %>",      // Tax Amount
        "<%= @order.adjustments.shipping.sum(:amount) %>", // Ship Amount
        "",                                                // City
        "",                                                // State
        ""                                                 // Country
      ]);
      <% @order.line_items.each do |line_item| %>
        _gaq.push(['_addItem',
          "<%= @order.number %>",                  // order ID - required
          "<%= line_item.variant.sku %>",          // SKU/code - required
          "<%= line_item.variant.product.name %>", // product name
          "",                                      // category or variation, Product Category
          "<%= line_item.price %>",                // unit price - required
          "<%= line_item.quantity %>"              // quantity - required
        ]);
      <% end %>
    <% end %>

    (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
  <% end %>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_core-1.2.0.rc2 app/views/spree/shared/_google_analytics.html.erb
spree_core-1.2.0.rc1 app/views/spree/shared/_google_analytics.html.erb