Sha256: 6ca29ef81f7ce4c5b9fbf1b03ff6489f4588b7007f0d19424a63ec333d6938f8

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 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] && @order.present? %>
      <%# more info: https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEcommerce %>
      _gaq.push(['_addTrans',
        "<%= j @order.number %>",
        "",
        "<%= @order.total %>",
        "<%= @order.adjustments.tax.sum(:amount) %>",
        "<%= @order.adjustments.shipping.sum(:amount) %>",
        "<%= j @order.bill_address.city %>",
        "<%= j @order.bill_address.state_text %>",
        "<%= j @order.bill_address.country.name %>"
      ]);
      <% @order.line_items.each do |line_item| %>
        _gaq.push(['_addItem',
          "<%= j @order.number %>",
          "<%= j line_item.variant.sku %>",
          "<%= j line_item.variant.product.name %>",
          "",
          "<%= line_item.price %>",
          "<%= line_item.quantity %>"
        ]);
      <% end %>
      _gaq.push(['_trackTrans']);
    <% end %>

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

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
spree_core-1.3.5 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.7 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.6 app/views/spree/shared/_google_analytics.html.erb
spree_core-1.3.4 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.5 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.4 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.3 app/views/spree/shared/_google_analytics.html.erb
spree_core-1.3.3 app/views/spree/shared/_google_analytics.html.erb
spree_core-1.2.5 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.2 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.1 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.0 app/views/spree/shared/_google_analytics.html.erb
spree_frontend-2.0.0.rc1 app/views/spree/shared/_google_analytics.html.erb