spree_gtm 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8cdad0d4b1e4982294e3e2e59cbabbc7b4d2071
4
- data.tar.gz: d0e2aa205de56ed3fa29a02f2c165d23d5fe50e9
3
+ metadata.gz: e6679eeab663ab0bb304bc0260df147a39135ef0
4
+ data.tar.gz: f01a439e6697e0a71bad497f779813ef9041e707
5
5
  SHA512:
6
- metadata.gz: 52922bb24cbc84b96a3ce202679af936625c021913bbd5bcd34db62ff7c3a3e14358b1c97ae526b10a122942ad2f4d0f39dc8f500c9590cb2b269f4d438a5016
7
- data.tar.gz: 9d03e4190df36827b975178d99c3456d6298239ddd4cdc226d2bdda9aa3c1c17892ec6152e03f55f6c79f343ecba2fe61236642ad909a700d5f4b991a171d237
6
+ metadata.gz: a72d2674bcfc621168de34a7b6efc622e2791125af5e07c558255a191556ad1306680168d14dff954ba0964723645cb42c5a490be5586f004d84e76a9863b282
7
+ data.tar.gz: c6f8e80e0823b23a0a4b8a57e752d912cf3deccaffbbd6f6fa7b716e51293a75bab7b891cc463b042ab48af49c603fbdcc2c46c66186800fbad50ba93b2c3880
@@ -1,26 +1,4 @@
1
1
  <% if Spree::Gtm.activated? %>
2
- <% if controller.controller_name == "orders" && controller.action_name == "show" %>
3
- <script>
4
- window.dataLayer = window.dataLayer || [];
5
- dataLayer.push({
6
- 'transactionId': '<%= @order.number %>',
7
- 'transactionTotal': <%= @order.total %>,
8
- 'transactionTax': <%= @order.adjustments.tax.sum(:amount) %>,
9
- 'transactionShipping': <%= @order.adjustments.shipping.sum(:amount) %>,
10
- 'transactionCity': '<%= @order.bill_address.city %>',
11
- 'transactionState': '<%= @order.bill_address.state_text %>',
12
- 'transactionZip': '<%= @order.bill_address.zipcode %>',
13
- 'transactionEmail': '<%= @order.email %>',
14
- 'transactionProducts': [
15
- <%=raw @order.line_items.map { |line_item| "{ 'sku': '#{h line_item.variant.sku}',
16
- 'name': '#{h line_item.variant.product.name}',
17
- 'category': '',
18
- 'price': #{h line_item.price},
19
- 'quantity': #{h line_item.quantity}}" } .join(",") %>
20
- ]
21
- });
22
- </script>
23
- <% end %>
24
2
  <!-- Google Tag Manager (noscript) -->
25
3
  <noscript>
26
4
  <iframe src="//www.googletagmanager.com/ns.html?id=<%= Spree::Gtm.gtm_accountid %>"
@@ -2,6 +2,7 @@
2
2
  <!-- Google Tag Manager -->
3
3
 
4
4
  <script>
5
+ dataLayer = [];
5
6
  (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
6
7
  new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
7
8
  j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
@@ -9,4 +10,40 @@
9
10
  })(window,document,'script','dataLayer','<%= Spree::Gtm.gtm_accountid %>');
10
11
  </script>
11
12
  <!-- End Google Tag Manager -->
13
+
14
+ <%= javascript_tag do %>
15
+ <% if @order.present? and @order.email.present? %>
16
+ dataLayer.push({'transactionEmail': '<%= @order.email %>'});
17
+ <% end %>
18
+ <% if @order.present? and @order.user.present? %>
19
+ dataLayer.push({'userid': '<%= @order.user.id %>'});
20
+ <% end %>
21
+ <% if flash[:commerce_tracking] and @order.present? %>
22
+
23
+ dataLayer.push({
24
+ 'transactionId': '<%= @order.number %>',
25
+ 'transactionAffiliation': 'Yourcompanyname',
26
+ 'transactionTotal': <%= @order.total %>,
27
+ 'transactionTax': <%= @order.adjustments.tax.sum(:amount) %>,
28
+ 'transactionShipping': <%= @order.adjustments.shipping.sum(:amount) %>,
29
+ 'transactionCity': '<%= @order.bill_address.city %>',
30
+ 'transactionState': '<%= @order.bill_address.state_text %>',
31
+ 'transactionZip': '<%= @order.bill_address.zipcode %>',
32
+ 'transactionEmail': '<%= @order.email %>',
33
+ 'transactionProducts': [
34
+ <%=raw @order.line_items.map { |line_item| "{ 'sku': '#{h line_item.variant.sku}',
35
+ 'name': '#{h line_item.variant.product.name}',
36
+ 'category': '',
37
+ 'price': #{h line_item.price},
38
+ 'quantity': #{h line_item.quantity}}" } .join(",") %>
39
+ ]
40
+ });
41
+
42
+ <% if @order.user.present? and @order.user.orders.complete.count==1 %>
43
+ dataLayer.push({
44
+ 'event': 'first_time_user_conversion'
45
+ });
46
+ <% end %>
47
+ <% end %>
48
+ <% end %>
12
49
  <% end %>
data/spree_gtm.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_gtm'
5
- s.version = '0.0.5'
5
+ s.version = '0.0.6'
6
6
  s.summary = 'some summary here'
7
7
  s.description = 'some gem description here'
8
8
  s.required_ruby_version = '>= 2.1.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_gtm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav O. Pogrebnyak