solidus_seo 1.0.12 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/decorators/controllers/spree/checkout_controller_decorator.rb +23 -0
- data/app/decorators/controllers/spree/orders_controller_decorator.rb +1 -0
- data/app/views/solidus_seo/_facebook.html.erb +52 -36
- data/app/views/solidus_seo/_google-analytics.html.erb +5 -5
- data/app/views/solidus_seo/_google-tag-manager.html.erb +22 -22
- data/app/views/solidus_seo/_pinterest.html.erb +45 -44
- data/lib/solidus_seo/version.rb +1 -1
- data/spec/examples.txt +40 -34
- data/spec/features/add_to_cart_spec.rb +10 -8
- data/spec/features/checkout_complete_spec.rb +1 -1
- data/spec/features/checkout_initiated_spec.rb +53 -0
- data/spec/features/homepage_spec.rb +1 -1
- data/spec/features/product_page_spec.rb +2 -2
- data/spec/features/taxon_page_spec.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b271de06999564680b05f6bc567792f8bf7fa7e6c5f6724657e99c11b49f9863
|
4
|
+
data.tar.gz: 6b02664bd4631e08156e8f844e0e8c366a164d59a2c4cda90e4e2f52f65a752e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf416b0189fde7be68c93ededdf8a1db518e4df9c9f1df826e54c5880654c6340413846ad318103aa201092cbdea1b72109d373a0894d0a5e4c97303d1c547c5
|
7
|
+
data.tar.gz: 71d3bfe67f0bf775289419f2e0cc1e70cac2719d8b54b17c083f5253350c83cd6d039ad57bbfdb8330aa4cb38266bc1f3a88cd6c97460786239c0a6c950e7246
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spree
|
4
|
+
module CheckoutControllerDecorator
|
5
|
+
def self.prepended(base)
|
6
|
+
base.class_eval do
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def before_address
|
11
|
+
flash[:checkout_initiated] =
|
12
|
+
@order.address? &&
|
13
|
+
request.referrer =~ /#{cart_path}\b/i &&
|
14
|
+
params[:action] == 'edit'
|
15
|
+
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
::Spree::StoreController.prepend(self)
|
22
|
+
end
|
23
|
+
end
|
@@ -26,6 +26,7 @@ module Spree
|
|
26
26
|
cart_diff = cart_diff.map do |variant_sku, quantity|
|
27
27
|
variant_hash = cart_diff_variant_payload(variant_sku)
|
28
28
|
variant_hash[:quantity] = quantity
|
29
|
+
variant_hash[:amount] = quantity * variant_hash[:price]
|
29
30
|
|
30
31
|
[variant_sku, variant_hash]
|
31
32
|
end.to_h
|
@@ -1,47 +1,58 @@
|
|
1
1
|
<%
|
2
2
|
return if ENV['FACEBOOK_PIXEL_ID'].blank?
|
3
3
|
|
4
|
-
|
5
|
-
add_to_cart_data = {}
|
6
|
-
order_data = {}
|
4
|
+
event_data = {}
|
7
5
|
|
8
|
-
if
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
if order.present?
|
7
|
+
if just_purchased
|
8
|
+
event_data[:order] = {
|
9
|
+
value: order.total,
|
10
|
+
currency: order.currency,
|
11
|
+
content_type: 'product',
|
12
|
+
contents: order.line_items.map do |line_item|
|
13
|
+
{ id: line_item.variant.sku, quantity: line_item.quantity }
|
14
|
+
end,
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
# custom properties
|
17
|
+
order_number: order.number,
|
18
|
+
item_total: order.item_total,
|
19
|
+
tax_total: order.tax_total,
|
20
|
+
ship_total: order.ship_total,
|
21
|
+
promo_total: order.promo_total
|
22
|
+
}
|
23
|
+
end
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
25
|
+
if flash[:added_to_cart].present?
|
26
|
+
event_data[:added_to_cart] = {
|
27
|
+
value: flash[:added_to_cart].sum { |sku, hash| hash['amount'].to_d },
|
28
|
+
currency: order.currency,
|
29
|
+
content_type: 'product',
|
30
|
+
contents: flash[:added_to_cart].map do |variant_sku, variant|
|
31
|
+
{ id: variant_sku, quantity: variant['quantity'] }
|
32
|
+
end
|
33
|
+
}
|
34
|
+
end
|
27
35
|
|
28
|
-
if flash[:
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
if flash[:checkout_initiated].present?
|
37
|
+
event_data[:checkout_initiated] = {
|
38
|
+
value: order.total,
|
39
|
+
currency: order.currency,
|
40
|
+
content_type: 'product',
|
41
|
+
contents: order.line_items.map do |line_item|
|
42
|
+
{ id: line_item.variant.sku, quantity: line_item.quantity }
|
43
|
+
end
|
44
|
+
}
|
45
|
+
end
|
36
46
|
end
|
37
47
|
|
38
48
|
if @product
|
39
|
-
|
49
|
+
event_data[:current_product] = {
|
40
50
|
content_type: 'product',
|
41
51
|
content_name: @product.name,
|
42
52
|
content_ids: [@product.master.sku]
|
43
53
|
}
|
44
54
|
end
|
55
|
+
|
45
56
|
%>
|
46
57
|
<script type="text/javascript" data-tag="facebook">
|
47
58
|
!function(f,b,e,v,n,t,s) {if (f.fbq) return;n = f.fbq = function() { n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments) };if (!f._fbq) f._fbq=n;n.push = n; n.loaded = !0; n.version = '2.0'; n.queue=[]; t = b.createElement(e); t.async = !0; t.src = v;s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s);}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js');
|
@@ -49,19 +60,24 @@ end
|
|
49
60
|
fbq('init', '<%= ENV['FACEBOOK_PIXEL_ID'] %>');
|
50
61
|
fbq('track', 'PageView');
|
51
62
|
|
52
|
-
<% if
|
53
|
-
fbq('track', 'Purchase', <%==
|
63
|
+
<% if event_data[:order].present? %>
|
64
|
+
fbq('track', 'Purchase', <%== event_data[:order].to_json %>);
|
54
65
|
window.solidusSeoDataLayer('facebook', 'purchase');
|
55
66
|
<% end %>
|
56
67
|
|
57
|
-
<% if
|
58
|
-
fbq('track', 'AddToCart', <%==
|
68
|
+
<% if event_data[:added_to_cart].present? %>
|
69
|
+
fbq('track', 'AddToCart', <%== event_data[:added_to_cart].to_json %>);
|
59
70
|
window.solidusSeoDataLayer('facebook', 'addtocart');
|
60
71
|
<% end %>
|
61
72
|
|
62
|
-
<% if
|
63
|
-
fbq('track', '
|
64
|
-
window.solidusSeoDataLayer('facebook', '
|
73
|
+
<% if event_data[:checkout_initiated].present? %>
|
74
|
+
fbq('track', 'InitiateCheckout', <%== event_data[:checkout_initiated].to_json %>);
|
75
|
+
window.solidusSeoDataLayer('facebook', 'initiatecheckout');
|
76
|
+
<% end %>
|
77
|
+
|
78
|
+
<% if event_data[:current_product].present? %>
|
79
|
+
fbq('track', 'ViewContent', <%== event_data[:current_product].to_json %>);
|
80
|
+
window.solidusSeoDataLayer('facebook', 'viewcontent');
|
65
81
|
<% end %>
|
66
82
|
</script>
|
67
83
|
<noscript>
|
@@ -1,13 +1,13 @@
|
|
1
1
|
<%
|
2
2
|
return if ENV['GOOGLE_TAG_MANAGER_ID'].present? || ENV['GOOGLE_ANALYTICS_ID'].blank?
|
3
3
|
|
4
|
+
event_data = {}
|
5
|
+
|
4
6
|
if just_purchased
|
5
|
-
|
7
|
+
event_data[:order] = {
|
6
8
|
transaction_id: order.number,
|
7
9
|
value: order.total,
|
8
10
|
items: order.line_items.map do |line_item|
|
9
|
-
next unless line_item.variant
|
10
|
-
|
11
11
|
{
|
12
12
|
id: line_item.variant.sku,
|
13
13
|
name: line_item.variant.name,
|
@@ -15,7 +15,7 @@ if just_purchased
|
|
15
15
|
variant: line_item.variant.options_text,
|
16
16
|
quantity: line_item.quantity
|
17
17
|
}
|
18
|
-
end
|
18
|
+
end,
|
19
19
|
|
20
20
|
affiliation: current_store.name,
|
21
21
|
currency: order.currency,
|
@@ -35,7 +35,7 @@ end
|
|
35
35
|
|
36
36
|
<% if just_purchased %>
|
37
37
|
<script data-tag="google-analytics">
|
38
|
-
gtag('event', 'purchase', <%==
|
38
|
+
gtag('event', 'purchase', <%== event_data[:order].to_json %>);
|
39
39
|
window.solidusSeoDataLayer('google-analytics', 'purchase');
|
40
40
|
</script>
|
41
41
|
<% end %>
|
@@ -1,29 +1,29 @@
|
|
1
1
|
<%
|
2
2
|
return if ENV['GOOGLE_ANALYTICS_ID'].present? || ENV['GOOGLE_TAG_MANAGER_ID'].blank?
|
3
3
|
|
4
|
-
|
5
|
-
order_data = {
|
6
|
-
id: order.number,
|
7
|
-
revenue: order.total,
|
8
|
-
coupon: '', # TODO: Add coupon code if present
|
9
|
-
|
10
|
-
affiliation: current_store.name,
|
11
|
-
currency: order.currency,
|
12
|
-
tax: order.tax_total,
|
13
|
-
shipping: order.ship_total
|
14
|
-
}
|
4
|
+
event_data = {}
|
15
5
|
|
16
|
-
|
17
|
-
|
6
|
+
if just_purchased
|
7
|
+
event_data[:order] = {
|
8
|
+
id: order.number,
|
9
|
+
revenue: order.total,
|
10
|
+
coupon: order.adjustments.promotion.first&.promotion_code&.value,
|
18
11
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
variant: line_item.variant.options_text,
|
24
|
-
quantity: line_item.quantity
|
12
|
+
affiliation: current_store.name,
|
13
|
+
currency: order.currency,
|
14
|
+
tax: order.tax_total,
|
15
|
+
shipping: order.ship_total
|
25
16
|
}
|
26
|
-
|
17
|
+
|
18
|
+
event_data[:order_contents] = order.line_items.map do |line_item|
|
19
|
+
{
|
20
|
+
id: line_item.variant.sku,
|
21
|
+
name: line_item.variant.name,
|
22
|
+
price: line_item.total,
|
23
|
+
variant: line_item.variant.options_text,
|
24
|
+
quantity: line_item.quantity
|
25
|
+
}
|
26
|
+
end
|
27
27
|
end
|
28
28
|
%>
|
29
29
|
<script type="text/javascript" data-tag="google-tag-manager">
|
@@ -33,8 +33,8 @@ end
|
|
33
33
|
window.dataLayer.push({
|
34
34
|
'ecommerce': {
|
35
35
|
'purchase': {
|
36
|
-
'actionField': <%==
|
37
|
-
'products': <%==
|
36
|
+
'actionField': <%== event_data[:order].to_json %>,
|
37
|
+
'products': <%== event_data[:order_contents].to_json %>
|
38
38
|
}
|
39
39
|
}
|
40
40
|
});
|
@@ -1,38 +1,55 @@
|
|
1
1
|
<%
|
2
2
|
return if ENV['PINTEREST_TAG_ID'].blank?
|
3
3
|
|
4
|
-
|
5
|
-
add_to_cart_data = {}
|
6
|
-
order_data = {}
|
7
|
-
em_data = {}
|
4
|
+
event_data = {}
|
8
5
|
|
9
6
|
user_email = try_spree_current_user&.email || current_order&.email
|
10
7
|
if user_email.present?
|
11
8
|
em_data = { em: user_email }
|
12
9
|
end
|
13
10
|
|
14
|
-
if
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
if order.present?
|
12
|
+
if just_purchased
|
13
|
+
event_data[:order] = {
|
14
|
+
value: order.total,
|
15
|
+
currency: order.currency,
|
16
|
+
order_quantity: order.line_items.sum(&:quantity),
|
17
|
+
line_items: order.line_items.map do |line_item|
|
18
|
+
next unless line_item.variant
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
20
|
+
{
|
21
|
+
product_id: line_item.variant.product.master.sku,
|
22
|
+
product_name: line_item.variant.name,
|
23
|
+
product_variant_id: line_item.variant.sku,
|
24
|
+
product_variant: line_item.variant.options_text,
|
25
|
+
product_quantity: line_item.quantity,
|
26
|
+
product_price: line_item.price
|
27
|
+
}
|
28
|
+
end.compact
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
if flash[:added_to_cart].present?
|
33
|
+
event_data[:added_to_cart] = {
|
34
|
+
value: flash[:added_to_cart].sum { |sku, hash| hash['amount'].to_d },
|
35
|
+
currency: order.currency,
|
36
|
+
order_id: order.number,
|
37
|
+
line_items: flash[:added_to_cart].map do |variant_sku, variant|
|
38
|
+
{
|
39
|
+
product_id: variant['id'],
|
40
|
+
product_name: variant['name'],
|
41
|
+
product_variant_id: variant_sku,
|
42
|
+
product_variant: variant['variant'],
|
43
|
+
product_price: variant['price'],
|
44
|
+
product_quantity: variant['quantity']
|
45
|
+
}
|
46
|
+
end
|
47
|
+
}
|
48
|
+
end
|
32
49
|
end
|
33
50
|
|
34
51
|
if @product
|
35
|
-
|
52
|
+
event_data[:product] = {
|
36
53
|
line_items: [
|
37
54
|
{
|
38
55
|
product_name: @product.name,
|
@@ -42,23 +59,7 @@ if @product
|
|
42
59
|
}
|
43
60
|
end
|
44
61
|
|
45
|
-
|
46
|
-
add_to_cart_data = {
|
47
|
-
value: order.total,
|
48
|
-
currency: order.currency,
|
49
|
-
order_id: order.number,
|
50
|
-
line_items: flash[:added_to_cart].map do |variant_sku, variant|
|
51
|
-
{
|
52
|
-
product_id: variant['id'],
|
53
|
-
product_name: variant['name'],
|
54
|
-
product_variant_id: variant_sku,
|
55
|
-
product_variant: variant['variant'],
|
56
|
-
product_price: variant['price'],
|
57
|
-
product_quantity: variant['quantity']
|
58
|
-
}
|
59
|
-
end
|
60
|
-
}
|
61
|
-
end
|
62
|
+
|
62
63
|
%>
|
63
64
|
<script type="text/javascript" data-tag="pinterest">
|
64
65
|
!function(e){if(!window.pintrk){window.pintrk=function(){window.pintrk.queue.push(Array.prototype.slice.call(arguments))};var n=window.pintrk;n.queue=[],n.version="3.0";var t=document.createElement("script");t.async=!0,t.src=e;var r=document.getElementsByTagName("script")[0];r.parentNode.insertBefore(t,r)}}("https://s.pinimg.com/ct/core.js");
|
@@ -66,16 +67,16 @@ end
|
|
66
67
|
pintrk('load', '<%= ENV['PINTEREST_TAG_ID'] %>' <%== em_data.present? ? ", #{em_data.to_json}" : '' %>);
|
67
68
|
pintrk('page');
|
68
69
|
|
69
|
-
pintrk('track', 'pagevisit'<%==
|
70
|
+
pintrk('track', 'pagevisit'<%== event_data[:product].present? ? ", #{event_data[:product].to_json}" : '' %>);
|
70
71
|
window.solidusSeoDataLayer('pinterest', 'pagevisit');
|
71
72
|
|
72
|
-
<% if
|
73
|
-
pintrk('track', 'addtocart', <%==
|
73
|
+
<% if event_data[:added_to_cart].present? %>
|
74
|
+
pintrk('track', 'addtocart', <%== event_data[:added_to_cart].to_json %>);
|
74
75
|
window.solidusSeoDataLayer('pinterest', 'addtocart');
|
75
76
|
<% end %>
|
76
77
|
|
77
|
-
<% if
|
78
|
-
pintrk('track', 'checkout', <%==
|
78
|
+
<% if event_data[:order].present? %>
|
79
|
+
pintrk('track', 'checkout', <%== event_data[:order].to_json %>);
|
79
80
|
window.solidusSeoDataLayer('pinterest', 'purchase');
|
80
81
|
<% end %>
|
81
82
|
</script>
|
data/lib/solidus_seo/version.rb
CHANGED
data/spec/examples.txt
CHANGED
@@ -1,34 +1,40 @@
|
|
1
|
-
example_id
|
2
|
-
|
3
|
-
./spec/features/add_to_cart_spec.rb[1:1:1]
|
4
|
-
./spec/features/add_to_cart_spec.rb[1:1
|
5
|
-
./spec/features/
|
6
|
-
./spec/features/checkout_complete_spec.rb[1:
|
7
|
-
./spec/features/checkout_complete_spec.rb[1:
|
8
|
-
./spec/features/checkout_complete_spec.rb[1:
|
9
|
-
./spec/features/
|
10
|
-
./spec/features/
|
11
|
-
./spec/features/
|
12
|
-
./spec/features/
|
13
|
-
./spec/features/
|
14
|
-
./spec/features/homepage_spec.rb[1:
|
15
|
-
./spec/features/homepage_spec.rb[1:
|
16
|
-
./spec/features/
|
17
|
-
./spec/features/
|
18
|
-
./spec/features/
|
19
|
-
./spec/features/
|
20
|
-
./spec/features/
|
21
|
-
./spec/features/product_page_spec.rb[1:
|
22
|
-
./spec/features/product_page_spec.rb[1:
|
23
|
-
./spec/features/product_page_spec.rb[1:3
|
24
|
-
./spec/features/product_page_spec.rb[1:
|
25
|
-
./spec/features/product_page_spec.rb[1:
|
26
|
-
./spec/features/
|
27
|
-
./spec/features/
|
28
|
-
./spec/features/
|
29
|
-
./spec/features/
|
30
|
-
./spec/features/
|
31
|
-
./spec/features/
|
32
|
-
./spec/features/taxon_page_spec.rb[1:
|
33
|
-
./spec/features/taxon_page_spec.rb[1:
|
34
|
-
./spec/features/taxon_page_spec.rb[1:
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------------------------- | ------- | --------------- |
|
3
|
+
./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 0.66081 seconds |
|
4
|
+
./spec/features/add_to_cart_spec.rb[1:2:1] | passed | 0.75237 seconds |
|
5
|
+
./spec/features/add_to_cart_spec.rb[1:2:2] | passed | 0.67545 seconds |
|
6
|
+
./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 1.07 seconds |
|
7
|
+
./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 0.58496 seconds |
|
8
|
+
./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.47447 seconds |
|
9
|
+
./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 0.63761 seconds |
|
10
|
+
./spec/features/checkout_initiated_spec.rb[1:1:1] | pending | 0.1245 seconds |
|
11
|
+
./spec/features/checkout_initiated_spec.rb[1:2:1] | pending | 0.11937 seconds |
|
12
|
+
./spec/features/checkout_initiated_spec.rb[1:3:1] | passed | 0.97884 seconds |
|
13
|
+
./spec/features/checkout_initiated_spec.rb[1:4:1] | pending | 0.12569 seconds |
|
14
|
+
./spec/features/homepage_spec.rb[1:1:1] | passed | 0.28455 seconds |
|
15
|
+
./spec/features/homepage_spec.rb[1:1:2] | passed | 0.2939 seconds |
|
16
|
+
./spec/features/homepage_spec.rb[1:2:1] | passed | 0.29915 seconds |
|
17
|
+
./spec/features/homepage_spec.rb[1:2:2] | passed | 0.28221 seconds |
|
18
|
+
./spec/features/homepage_spec.rb[1:3:1] | passed | 0.36746 seconds |
|
19
|
+
./spec/features/homepage_spec.rb[1:3:2] | passed | 0.30991 seconds |
|
20
|
+
./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.49752 seconds |
|
21
|
+
./spec/features/product_page_spec.rb[1:1:1] | passed | 3.76 seconds |
|
22
|
+
./spec/features/product_page_spec.rb[1:1:2] | passed | 0.46834 seconds |
|
23
|
+
./spec/features/product_page_spec.rb[1:1:3] | passed | 0.43108 seconds |
|
24
|
+
./spec/features/product_page_spec.rb[1:2:1] | passed | 0.43884 seconds |
|
25
|
+
./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.37689 seconds |
|
26
|
+
./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.40017 seconds |
|
27
|
+
./spec/features/product_page_spec.rb[1:3:1] | passed | 0.34652 seconds |
|
28
|
+
./spec/features/product_page_spec.rb[1:3:2] | passed | 0.42483 seconds |
|
29
|
+
./spec/features/product_page_spec.rb[1:3:3] | passed | 0.38935 seconds |
|
30
|
+
./spec/features/product_page_spec.rb[1:4:1:1] | passed | 0.58891 seconds |
|
31
|
+
./spec/features/product_page_spec.rb[1:4:2:1] | passed | 0.92141 seconds |
|
32
|
+
./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.45357 seconds |
|
33
|
+
./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.37813 seconds |
|
34
|
+
./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.4267 seconds |
|
35
|
+
./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.43519 seconds |
|
36
|
+
./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.41135 seconds |
|
37
|
+
./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.42165 seconds |
|
38
|
+
./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.41839 seconds |
|
39
|
+
./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.39104 seconds |
|
40
|
+
./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.66123 seconds |
|
@@ -1,17 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe 'Add to cart', type: :system do
|
4
|
-
let!(:store) {
|
5
|
-
let!(:
|
6
|
-
let
|
4
|
+
let!(:store) { create(:store) }
|
5
|
+
let!(:product) { create(:product) }
|
6
|
+
let(:line_item_quantity) { 2 }
|
7
|
+
let(:order) { Spree::Order.last }
|
8
|
+
let(:line_item) { order.line_items.first }
|
7
9
|
|
8
10
|
stub_authorization!
|
9
11
|
|
10
12
|
before do
|
11
|
-
current_order_stubs(order)
|
12
13
|
stub_const 'ENV', ENV.to_h.merge(env_variable => 'XXX-YYYYY')
|
13
14
|
|
14
|
-
visit spree.product_path(
|
15
|
+
visit spree.product_path(product)
|
16
|
+
fill_in('quantity', with: line_item_quantity)
|
15
17
|
find('#add-to-cart-button').click
|
16
18
|
end
|
17
19
|
|
@@ -20,7 +22,7 @@ describe 'Add to cart', type: :system do
|
|
20
22
|
|
21
23
|
it 'tracks "add to cart" event with product data' do
|
22
24
|
expect(page).to track_analytics_event :facebook, 'addtocart', [
|
23
|
-
'fbq', 'track', 'AddToCart', line_item.sku
|
25
|
+
'fbq', 'track', 'AddToCart', line_item.amount, line_item.sku
|
24
26
|
]
|
25
27
|
end
|
26
28
|
end
|
@@ -30,8 +32,8 @@ describe 'Add to cart', type: :system do
|
|
30
32
|
|
31
33
|
it 'tracks "add to cart" event' do
|
32
34
|
expect(page).to track_analytics_event :pinterest, 'addtocart', [
|
33
|
-
'track', 'addtocart',
|
34
|
-
line_item.name, line_item.
|
35
|
+
'track', 'addtocart', line_item.amount, order.number, line_item.product.sku,
|
36
|
+
line_item.name, line_item.sku, line_item.price
|
35
37
|
]
|
36
38
|
end
|
37
39
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe 'Checkout complete', type: :system do
|
4
|
-
let!(:store) {
|
4
|
+
let!(:store) { create(:store) }
|
5
5
|
let!(:taxon) { create :taxon, name: 'MyTaxon' }
|
6
6
|
let!(:order) { create :completed_order_with_totals }
|
7
7
|
let!(:line_item) { order.line_items.first }
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'Checkout initated', type: :system do
|
4
|
+
let!(:store) { create(:store) }
|
5
|
+
let!(:taxon) { create :taxon, name: 'MyTaxon' }
|
6
|
+
let!(:product) { create(:base_product, taxons: [taxon]) }
|
7
|
+
let(:order) { Spree::Order.last }
|
8
|
+
|
9
|
+
stub_authorization!
|
10
|
+
|
11
|
+
before do
|
12
|
+
stub_const 'ENV', ENV.to_h.merge(env_variable => 'XXX-YYYYY')
|
13
|
+
end
|
14
|
+
|
15
|
+
subject do
|
16
|
+
visit spree.product_path(product)
|
17
|
+
find('#add-to-cart-button').click
|
18
|
+
find('#checkout-link').click
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when GOOGLE_TAG_MANAGER_ID environment variable is present' do
|
22
|
+
let(:env_variable) { 'GOOGLE_TAG_MANAGER_ID' }
|
23
|
+
|
24
|
+
it 'tracks "InitiateCheckout" event with product data' do
|
25
|
+
skip
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when GOOGLE_ANALYTICS_ID environment variable is present' do
|
30
|
+
let(:env_variable) { 'GOOGLE_ANALYTICS_ID' }
|
31
|
+
|
32
|
+
it 'tracks "InitiateCheckout" event with product data' do
|
33
|
+
skip
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when FACEBOOK_PIXEL_ID environment variable is present' do
|
38
|
+
let(:env_variable) { 'FACEBOOK_PIXEL_ID' }
|
39
|
+
|
40
|
+
it 'tracks "InitiateCheckout" event with product data' do
|
41
|
+
subject
|
42
|
+
expect(page).to track_analytics_event :facebook, 'initiatecheckout', ['track', 'InitiateCheckout', order.total, order.currency, order.line_items.first.sku]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when PINTEREST_TAG_ID environment variable is present' do
|
47
|
+
let(:env_variable) { 'PINTEREST_TAG_ID' }
|
48
|
+
|
49
|
+
it 'tracks "checkout" event with product data' do
|
50
|
+
skip
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe "Product page", type: :system do
|
2
|
-
let!(:store) {
|
2
|
+
let!(:store) { create(:store) }
|
3
3
|
let(:store_seo_name) { 'My store SEO name' }
|
4
4
|
|
5
5
|
let!(:taxon) { create(:taxon, name: 'MyTaxon') }
|
@@ -102,7 +102,7 @@ describe "Product page", type: :system do
|
|
102
102
|
|
103
103
|
it 'tracks "ViewContent" event with product data' do
|
104
104
|
subject
|
105
|
-
expect(page).to track_analytics_event :facebook, '
|
105
|
+
expect(page).to track_analytics_event :facebook, 'viewcontent', [
|
106
106
|
'fbq', 'track', 'ViewContent', product.name, product.master.sku
|
107
107
|
]
|
108
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_seo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karma Creative
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -337,6 +337,7 @@ files:
|
|
337
337
|
- app/assets/javascripts/spree/frontend/solidus_seo.js
|
338
338
|
- app/assets/stylesheets/spree/backend/solidus_seo.css
|
339
339
|
- app/assets/stylesheets/spree/frontend/solidus_seo.css
|
340
|
+
- app/decorators/controllers/spree/checkout_controller_decorator.rb
|
340
341
|
- app/decorators/controllers/spree/orders_controller_decorator.rb
|
341
342
|
- app/decorators/controllers/spree/store_controller_decorator.rb
|
342
343
|
- app/decorators/helpers/spree/core/controller_helpers/common_decorator.rb
|
@@ -383,6 +384,7 @@ files:
|
|
383
384
|
- spec/examples.txt
|
384
385
|
- spec/features/add_to_cart_spec.rb
|
385
386
|
- spec/features/checkout_complete_spec.rb
|
387
|
+
- spec/features/checkout_initiated_spec.rb
|
386
388
|
- spec/features/homepage_spec.rb
|
387
389
|
- spec/features/product_page_spec.rb
|
388
390
|
- spec/features/taxon_page_spec.rb
|
@@ -417,6 +419,7 @@ test_files:
|
|
417
419
|
- spec/spec_helper.rb
|
418
420
|
- spec/examples.txt
|
419
421
|
- spec/features/checkout_complete_spec.rb
|
422
|
+
- spec/features/checkout_initiated_spec.rb
|
420
423
|
- spec/features/homepage_spec.rb
|
421
424
|
- spec/features/taxon_page_spec.rb
|
422
425
|
- spec/features/add_to_cart_spec.rb
|