Sha256: 6d6199826f866e0161962d7c24c667b3a4ad2e7958be8e69ef4e4d76272aabab
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
<% return if ENV['GOOGLE_TAG_MANAGER_ID'].present? || ENV['GOOGLE_ANALYTICS_ID'].blank? event_data = {} if just_purchased event_data[:order] = { transaction_id: order.number, value: order.total, items: order.line_items.map do |line_item| { id: line_item.variant.sku, name: line_item.variant.name, price: line_item.price, variant: line_item.variant.options_text, quantity: line_item.quantity } end, affiliation: current_store.name, currency: order.currency, tax: order.tax_total, shipping: order.ship_total } end %> <script async src="https://www.googletagmanager.com/gtag/js?id=<%= ENV['GOOGLE_ANALYTICS_ID'] %>"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', '<%= ENV['GOOGLE_ANALYTICS_ID'] %>'); </script> <% if just_purchased %> <script data-tag="google-analytics"> gtag('event', 'purchase', <%== event_data[:order].to_json %>); window.solidusSeoDataLayer('google-analytics', 'purchase'); </script> <% end %>
Version data entries
3 entries across 3 versions & 1 rubygems