spree_gtm 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6679eeab663ab0bb304bc0260df147a39135ef0
|
4
|
+
data.tar.gz: f01a439e6697e0a71bad497f779813ef9041e707
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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