Sha256: 8fb8ade33e142ccf6186582c69b1eb84881a584cc1a3eb2bdc3a6494abeb2b21

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 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

1 entries across 1 versions & 1 rubygems

Version Path
spree_core-1.0.7 app/views/spree/shared/_google_analytics.html.erb