solidus_seo 1.0.10 → 1.1.0
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 +4 -4
- data/README.md +2 -0
- data/app/decorators/controllers/spree/checkout_controller_decorator.rb +23 -0
- data/app/decorators/models/spree/product_decorator.rb +2 -2
- data/app/views/solidus_seo/_facebook.html.erb +64 -18
- data/app/views/solidus_seo/_google-analytics.html.erb +16 -15
- data/app/views/solidus_seo/_google-tag-manager.html.erb +24 -23
- data/app/views/solidus_seo/_noscript_tags.html.erb +7 -0
- data/app/views/solidus_seo/_pinterest.html.erb +45 -44
- data/lib/generators/solidus_seo/install/install_generator.rb +2 -0
- data/lib/generators/solidus_seo/install/templates/insert_noscript_tags.html.erb.deface +4 -0
- data/lib/generators/solidus_seo/install/templates/replace_flash_messages_helper.html.erb.deface +5 -0
- data/lib/solidus_seo/jsonld/tag_helper.rb +1 -1
- data/lib/solidus_seo/version.rb +1 -1
- data/spec/examples.txt +40 -32
- data/spec/features/add_to_cart_spec.rb +15 -1
- data/spec/features/checkout_complete_spec.rb +5 -5
- data/spec/features/checkout_initiated_spec.rb +53 -0
- data/spec/features/homepage_spec.rb +16 -1
- data/spec/features/product_page_spec.rb +12 -1
- data/spec/features/taxon_page_spec.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb1033fb7f4c045f1f04ea722bcc18b6e2eca0a2d439ccd770405cfe9b2c975
|
4
|
+
data.tar.gz: 9af5e2eccfcd86fe5e1b58ac64753082d7d5ec0554534e0bf4ad58f6575f997c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf61b372e03d5c2e5858771993534722cae657cc7354887454d34cd57f49e439f83afe6678e286f57c9603d5a9cbe22a2c77d4dce3459987962c72287799d3b9
|
7
|
+
data.tar.gz: 13643cee45aef5965a2a1bbe346494f07efd3feb81baea9f9edebb43e045aa915a4430cc900356aad3c36a39b9173cd42389386393a14369bf4b7b883ef3005a
|
data/README.md
CHANGED
@@ -45,8 +45,10 @@ Here are the changes we make, via deface, in the default Solidus views as part o
|
|
45
45
|
|
46
46
|
- In `spree/layouts/spree_application.html.erb`
|
47
47
|
- Insert `<%= render 'solidus_seo/analytics' %>` just before `</head>`.
|
48
|
+
- Insert `<%= render 'solidus_seo/noscript_tags' %>` immediately after the `<body>` opening tag.
|
48
49
|
- Insert `<%= dump_jsonld %>` just before the `</body>` closing tag.
|
49
50
|
- Replace `<%= taxon_breadcrumbs(@taxon) %>` with (`<%= taxon_breadcrumbs_jsonld(@taxon) %>`) which does the same as the original plus prints a JSON-LD tag.
|
51
|
+
- Replace `<%= flash_messages %>` with (`<%= flash_messages(ignore_types: 'added_to_cart') %>`) which does the same as the original plus prints a JSON-LD tag.
|
50
52
|
|
51
53
|
- In `spree/products/show.html.erb`:
|
52
54
|
- Insert `<%= jsonld @product %>` anywhere inside the `cache` block.
|
@@ -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
|
@@ -17,10 +17,10 @@ module Spree
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def seo_images
|
20
|
-
return [] unless
|
20
|
+
return [] unless gallery.images.any? && gallery.images.first.attachment.file?
|
21
21
|
|
22
22
|
[
|
23
|
-
url_helper.image_url(
|
23
|
+
url_helper.image_url(gallery.images.first.attachment.url(:large), host: store_host),
|
24
24
|
].compact
|
25
25
|
end
|
26
26
|
|
@@ -1,25 +1,56 @@
|
|
1
1
|
<%
|
2
2
|
return if ENV['FACEBOOK_PIXEL_ID'].blank?
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
event_data = {}
|
5
|
+
|
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
|
+
|
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
|
24
|
+
|
25
|
+
if flash[:added_to_cart].present?
|
26
|
+
event_data[:added_to_cart] = {
|
27
|
+
currency: order.currency,
|
28
|
+
content_type: 'product',
|
29
|
+
contents: flash[:added_to_cart].map do |variant_sku, variant|
|
30
|
+
{ id: variant_sku, quantity: variant['quantity'] }
|
31
|
+
end
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
if flash[:checkout_initiated].present?
|
36
|
+
event_data[:checkout_initiated] = {
|
37
|
+
value: order.total,
|
38
|
+
currency: order.currency,
|
39
|
+
contents: order.line_items.map do |line_item|
|
40
|
+
{ id: line_item.variant.sku, quantity: line_item.quantity }
|
41
|
+
end
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if @product
|
47
|
+
event_data[:current_product] = {
|
8
48
|
content_type: 'product',
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
{ id: line_item.variant.sku, quantity: line_item.quantity }
|
13
|
-
end.compact,
|
14
|
-
|
15
|
-
# custom properties
|
16
|
-
order_number: order.number,
|
17
|
-
item_total: order.item_total,
|
18
|
-
tax_total: order.tax_total,
|
19
|
-
ship_total: order.ship_total,
|
20
|
-
promo_total: order.promo_total
|
49
|
+
content_name: @product.name,
|
50
|
+
content_ids: [@product.master.sku]
|
21
51
|
}
|
22
52
|
end
|
53
|
+
|
23
54
|
%>
|
24
55
|
<script type="text/javascript" data-tag="facebook">
|
25
56
|
!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');
|
@@ -27,10 +58,25 @@ end
|
|
27
58
|
fbq('init', '<%= ENV['FACEBOOK_PIXEL_ID'] %>');
|
28
59
|
fbq('track', 'PageView');
|
29
60
|
|
30
|
-
<% if
|
31
|
-
fbq('track', 'Purchase', <%==
|
61
|
+
<% if event_data[:order].present? %>
|
62
|
+
fbq('track', 'Purchase', <%== event_data[:order].to_json %>);
|
32
63
|
window.solidusSeoDataLayer('facebook', 'purchase');
|
33
64
|
<% end %>
|
65
|
+
|
66
|
+
<% if event_data[:added_to_cart].present? %>
|
67
|
+
fbq('track', 'AddToCart', <%== event_data[:added_to_cart].to_json %>);
|
68
|
+
window.solidusSeoDataLayer('facebook', 'addtocart');
|
69
|
+
<% end %>
|
70
|
+
|
71
|
+
<% if event_data[:checkout_initiated].present? %>
|
72
|
+
fbq('track', 'InitiateCheckout', <%== event_data[:checkout_initiated].to_json %>);
|
73
|
+
window.solidusSeoDataLayer('facebook', 'initiatecheckout');
|
74
|
+
<% end %>
|
75
|
+
|
76
|
+
<% if event_data[:current_product].present? %>
|
77
|
+
fbq('track', 'ViewContent', <%== event_data[:current_product].to_json %>);
|
78
|
+
window.solidusSeoDataLayer('facebook', 'viewcontent');
|
79
|
+
<% end %>
|
34
80
|
</script>
|
35
81
|
<noscript>
|
36
82
|
<img height="1" width="1" src="https://www.facebook.com/tr?id=<%= ENV['FACEBOOK_PIXEL_ID'] %>&ev=PageView&noscript=1" />
|
@@ -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,
|
@@ -25,16 +25,17 @@ if just_purchased
|
|
25
25
|
end
|
26
26
|
%>
|
27
27
|
<script async src="https://www.googletagmanager.com/gtag/js?id=<%= ENV['GOOGLE_ANALYTICS_ID'] %>"></script>
|
28
|
-
<script
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
<script>
|
29
|
+
window.dataLayer = window.dataLayer || [];
|
30
|
+
function gtag(){dataLayer.push(arguments);}
|
31
|
+
gtag('js', new Date());
|
32
32
|
|
33
|
-
|
34
|
-
gtag('config', '<%= ENV['GOOGLE_ANALYTICS_ID'] %>');
|
35
|
-
|
36
|
-
<% if just_purchased %>
|
37
|
-
gtag('event', 'purchase', <%== order_data.to_json %>);
|
38
|
-
window.solidusSeoDataLayer('google-analytics', 'purchase');
|
39
|
-
<% end %>
|
33
|
+
gtag('config', '<%= ENV['GOOGLE_ANALYTICS_ID'] %>');
|
40
34
|
</script>
|
35
|
+
|
36
|
+
<% if just_purchased %>
|
37
|
+
<script data-tag="google-analytics">
|
38
|
+
gtag('event', 'purchase', <%== event_data[:order].to_json %>);
|
39
|
+
window.solidusSeoDataLayer('google-analytics', 'purchase');
|
40
|
+
</script>
|
41
|
+
<% end %>
|
@@ -1,11 +1,13 @@
|
|
1
1
|
<%
|
2
2
|
return if ENV['GOOGLE_ANALYTICS_ID'].present? || ENV['GOOGLE_TAG_MANAGER_ID'].blank?
|
3
3
|
|
4
|
+
event_data = {}
|
5
|
+
|
4
6
|
if just_purchased
|
5
|
-
|
7
|
+
event_data[:order] = {
|
6
8
|
id: order.number,
|
7
9
|
revenue: order.total,
|
8
|
-
coupon:
|
10
|
+
coupon: order.adjustments.promotion.first&.promotion_code&.value,
|
9
11
|
|
10
12
|
affiliation: current_store.name,
|
11
13
|
currency: order.currency,
|
@@ -13,9 +15,7 @@ if just_purchased
|
|
13
15
|
shipping: order.ship_total
|
14
16
|
}
|
15
17
|
|
16
|
-
|
17
|
-
next unless line_item.variant
|
18
|
-
|
18
|
+
event_data[:order_contents] = order.line_items.map do |line_item|
|
19
19
|
{
|
20
20
|
id: line_item.variant.sku,
|
21
21
|
name: line_item.variant.name,
|
@@ -23,28 +23,29 @@ if just_purchased
|
|
23
23
|
variant: line_item.variant.options_text,
|
24
24
|
quantity: line_item.quantity
|
25
25
|
}
|
26
|
-
end
|
26
|
+
end
|
27
27
|
end
|
28
28
|
%>
|
29
29
|
<script type="text/javascript" data-tag="google-tag-manager">
|
30
|
-
|
31
|
-
|
32
|
-
<% if just_purchased %>
|
33
|
-
window.dataLayer.push({
|
34
|
-
'ecommerce': {
|
35
|
-
'purchase': {
|
36
|
-
'actionField': <%== order_data.to_json %>,
|
37
|
-
'products': <%== purchased_items.to_json %>
|
38
|
-
}
|
39
|
-
}
|
40
|
-
});
|
30
|
+
window.dataLayer = window.dataLayer || [];
|
41
31
|
|
42
|
-
|
43
|
-
|
32
|
+
<% if just_purchased %>
|
33
|
+
window.dataLayer.push({
|
34
|
+
'ecommerce': {
|
35
|
+
'purchase': {
|
36
|
+
'actionField': <%== event_data[:order].to_json %>,
|
37
|
+
'products': <%== event_data[:order_contents].to_json %>
|
38
|
+
}
|
39
|
+
}
|
40
|
+
});
|
44
41
|
|
45
|
-
(
|
42
|
+
window.solidusSeoDataLayer('google-tag-manager', 'purchase');
|
43
|
+
<% end %>
|
44
|
+
</script>
|
45
|
+
<script>
|
46
|
+
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
46
47
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
49
|
+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
50
|
+
})(window,document,'script','dataLayer','<%= ENV['GOOGLE_TAG_MANAGER_ID'] %>');
|
50
51
|
</script>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%
|
2
|
+
return if ENV['GOOGLE_TAG_MANAGER_ID'].blank?
|
3
|
+
%>
|
4
|
+
<!-- Google Tag Manager (noscript) -->
|
5
|
+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=<%= ENV['GOOGLE_TAG_MANAGER_ID'] %>"
|
6
|
+
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
|
7
|
+
<!-- End Google Tag Manager (noscript) -->
|
@@ -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: order.total,
|
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>
|
@@ -35,6 +35,8 @@ module SolidusSeo
|
|
35
35
|
copy_file 'insert_product_list_helper.html.erb.deface', 'app/overrides/spree/shared/_products/insert_product_list_helper.html.erb.deface'
|
36
36
|
copy_file 'insert_analytics_in_layout.html.erb.deface', 'app/overrides/spree/layouts/spree_application/insert_analytics_in_layout.html.erb.deface'
|
37
37
|
copy_file 'replace_taxon_breadcrumbs_helper.html.erb.deface', 'app/overrides/spree/layouts/spree_application/replace_taxon_breadcrumbs_helper.html.erb.deface'
|
38
|
+
copy_file 'insert_noscript_tags.html.erb.deface', 'app/overrides/spree/layouts/spree_application/insert_noscript_tags.html.erb.deface'
|
39
|
+
copy_file 'replace_flash_messages_helper.html.erb.deface', 'app/overrides/spree/layouts/spree_application/replace_flash_messages_helper.html.erb.deface'
|
38
40
|
end
|
39
41
|
end
|
40
42
|
end
|
data/lib/solidus_seo/version.rb
CHANGED
data/spec/examples.txt
CHANGED
@@ -1,32 +1,40 @@
|
|
1
|
-
example_id
|
2
|
-
|
3
|
-
./spec/features/add_to_cart_spec.rb[1:1:1]
|
4
|
-
./spec/features/
|
5
|
-
./spec/features/
|
6
|
-
./spec/features/checkout_complete_spec.rb[1:
|
7
|
-
./spec/features/checkout_complete_spec.rb[1:
|
8
|
-
./spec/features/
|
9
|
-
./spec/features/
|
10
|
-
./spec/features/
|
11
|
-
./spec/features/
|
12
|
-
./spec/features/
|
13
|
-
./spec/features/
|
14
|
-
./spec/features/
|
15
|
-
./spec/features/
|
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:
|
24
|
-
./spec/features/
|
25
|
-
./spec/features/
|
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:
|
1
|
+
example_id | status | run_time |
|
2
|
+
------------------------------------------------- | ------- | --------------- |
|
3
|
+
./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 0.88876 seconds |
|
4
|
+
./spec/features/add_to_cart_spec.rb[1:2:1] | passed | 1.67 seconds |
|
5
|
+
./spec/features/add_to_cart_spec.rb[1:2:2] | passed | 0.81532 seconds |
|
6
|
+
./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 0.49475 seconds |
|
7
|
+
./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 0.63596 seconds |
|
8
|
+
./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.4408 seconds |
|
9
|
+
./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 0.54652 seconds |
|
10
|
+
./spec/features/checkout_initiated_spec.rb[1:1:1] | pending | 1.46 seconds |
|
11
|
+
./spec/features/checkout_initiated_spec.rb[1:2:1] | pending | 0.11918 seconds |
|
12
|
+
./spec/features/checkout_initiated_spec.rb[1:3:1] | passed | 3.12 seconds |
|
13
|
+
./spec/features/checkout_initiated_spec.rb[1:4:1] | pending | 0.1185 seconds |
|
14
|
+
./spec/features/homepage_spec.rb[1:1:1] | passed | 0.26686 seconds |
|
15
|
+
./spec/features/homepage_spec.rb[1:1:2] | passed | 0.31045 seconds |
|
16
|
+
./spec/features/homepage_spec.rb[1:2:1] | passed | 0.36642 seconds |
|
17
|
+
./spec/features/homepage_spec.rb[1:2:2] | passed | 0.29678 seconds |
|
18
|
+
./spec/features/homepage_spec.rb[1:3:1] | passed | 0.29245 seconds |
|
19
|
+
./spec/features/homepage_spec.rb[1:3:2] | passed | 0.2174 seconds |
|
20
|
+
./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.54381 seconds |
|
21
|
+
./spec/features/product_page_spec.rb[1:1:1] | passed | 0.39065 seconds |
|
22
|
+
./spec/features/product_page_spec.rb[1:1:2] | passed | 0.40425 seconds |
|
23
|
+
./spec/features/product_page_spec.rb[1:1:3] | passed | 0.38355 seconds |
|
24
|
+
./spec/features/product_page_spec.rb[1:2:1] | passed | 0.40304 seconds |
|
25
|
+
./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.42235 seconds |
|
26
|
+
./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.39108 seconds |
|
27
|
+
./spec/features/product_page_spec.rb[1:3:1] | passed | 0.38062 seconds |
|
28
|
+
./spec/features/product_page_spec.rb[1:3:2] | passed | 0.37097 seconds |
|
29
|
+
./spec/features/product_page_spec.rb[1:3:3] | passed | 0.34059 seconds |
|
30
|
+
./spec/features/product_page_spec.rb[1:4:1:1] | passed | 0.40027 seconds |
|
31
|
+
./spec/features/product_page_spec.rb[1:4:2:1] | passed | 0.52408 seconds |
|
32
|
+
./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.40921 seconds |
|
33
|
+
./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.44084 seconds |
|
34
|
+
./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.38952 seconds |
|
35
|
+
./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.3867 seconds |
|
36
|
+
./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.39532 seconds |
|
37
|
+
./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.37653 seconds |
|
38
|
+
./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.36491 seconds |
|
39
|
+
./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.38757 seconds |
|
40
|
+
./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.58312 seconds |
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe 'Add to cart', type: :system do
|
4
|
-
let!(:store) {
|
4
|
+
let!(:store) { create(:store) }
|
5
5
|
let!(:order) { create :completed_order_with_totals }
|
6
6
|
let!(:line_item) { order.line_items.first }
|
7
7
|
|
@@ -15,6 +15,16 @@ describe 'Add to cart', type: :system do
|
|
15
15
|
find('#add-to-cart-button').click
|
16
16
|
end
|
17
17
|
|
18
|
+
context 'when FACEBOOK_PIXEL_ID environment variable is present' do
|
19
|
+
let(:env_variable) { 'FACEBOOK_PIXEL_ID' }
|
20
|
+
|
21
|
+
it 'tracks "add to cart" event with product data' do
|
22
|
+
expect(page).to track_analytics_event :facebook, 'addtocart', [
|
23
|
+
'fbq', 'track', 'AddToCart', line_item.sku
|
24
|
+
]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
18
28
|
context 'when PINTEREST_TAG_ID environment variable is present' do
|
19
29
|
let(:env_variable) { 'PINTEREST_TAG_ID' }
|
20
30
|
|
@@ -24,6 +34,10 @@ describe 'Add to cart', type: :system do
|
|
24
34
|
line_item.name, line_item.variant.sku, line_item.variant.price
|
25
35
|
]
|
26
36
|
end
|
37
|
+
|
38
|
+
it 'skips printing a flash message to the user with added_to_cart raw data' do
|
39
|
+
expect(page).to_not have_css '.flash.added_to_cart'
|
40
|
+
end
|
27
41
|
end
|
28
42
|
end
|
29
43
|
|
@@ -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 }
|
@@ -19,7 +19,7 @@ describe 'Checkout complete', type: :system do
|
|
19
19
|
context 'when GOOGLE_TAG_MANAGER_ID environment variable is present' do
|
20
20
|
let(:env_variable) { 'GOOGLE_TAG_MANAGER_ID' }
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'tracks "purchase" event with product data' do
|
23
23
|
subject
|
24
24
|
expect(page).to track_analytics_event 'google-tag-manager', 'purchase', ['ecommerce', 'purchase', order.number, order.total, line_item.sku]
|
25
25
|
end
|
@@ -28,7 +28,7 @@ describe 'Checkout complete', type: :system do
|
|
28
28
|
context 'when GOOGLE_ANALYTICS_ID environment variable is present' do
|
29
29
|
let(:env_variable) { 'GOOGLE_ANALYTICS_ID' }
|
30
30
|
|
31
|
-
it '
|
31
|
+
it 'tracks "purchase" event with product data' do
|
32
32
|
subject
|
33
33
|
expect(page).to track_analytics_event 'google-analytics', 'purchase', [
|
34
34
|
'event', 'purchase', 'transaction_id', order.number,
|
@@ -41,7 +41,7 @@ describe 'Checkout complete', type: :system do
|
|
41
41
|
context 'when FACEBOOK_PIXEL_ID environment variable is present' do
|
42
42
|
let(:env_variable) { 'FACEBOOK_PIXEL_ID' }
|
43
43
|
|
44
|
-
it '
|
44
|
+
it 'tracks "Purchase" event with product data' do
|
45
45
|
subject
|
46
46
|
expect(page).to track_analytics_event :facebook, 'purchase', ['track', 'Purchase', order.total, line_item.sku, line_item.quantity, order.number]
|
47
47
|
end
|
@@ -50,7 +50,7 @@ describe 'Checkout complete', type: :system do
|
|
50
50
|
context 'when PINTEREST_TAG_ID environment variable is present' do
|
51
51
|
let(:env_variable) { 'PINTEREST_TAG_ID' }
|
52
52
|
|
53
|
-
it '
|
53
|
+
it 'tracks "checkout" event with product data' do
|
54
54
|
subject
|
55
55
|
expect(page).to track_analytics_event :pinterest, 'purchase', ['track', 'checkout', order.total, line_item.sku, line_item.name, line_item.price]
|
56
56
|
end
|
@@ -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 "Homepage", type: :system do
|
2
|
-
let!(:store) {
|
2
|
+
let!(:store) { create(:store) }
|
3
3
|
let(:seo_name) { 'My store SEO name' }
|
4
4
|
let(:seo_image) { 'https://example.com/path/store.jpg' }
|
5
5
|
let(:seo_description) { 'My store SEO description' }
|
@@ -59,4 +59,19 @@ describe "Homepage", type: :system do
|
|
59
59
|
expect(page).to have_css "meta[property='og:description'][content='#{seo_description}']", visible: false
|
60
60
|
end
|
61
61
|
end
|
62
|
+
|
63
|
+
context 'noscript tags' do
|
64
|
+
context 'when GOOGLE_TAG_MANAGER_ID is present' do
|
65
|
+
let(:env_variable) { 'GOOGLE_TAG_MANAGER_ID' }
|
66
|
+
|
67
|
+
before do
|
68
|
+
stub_const 'ENV', ENV.to_h.merge(env_variable => 'XXX-YYYYY')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'contains noscript tag for GTM' do
|
72
|
+
subject
|
73
|
+
expect(page).to have_text :all, "https://www.googletagmanager.com/ns.html"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
62
77
|
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') }
|
@@ -97,6 +97,17 @@ describe "Product page", type: :system do
|
|
97
97
|
stub_const 'ENV', ENV.to_h.merge(env_variable => 'XXX-YYYYY')
|
98
98
|
end
|
99
99
|
|
100
|
+
context 'when FACEBOOK_PIXEL_ID environment variable is present' do
|
101
|
+
let(:env_variable) { 'FACEBOOK_PIXEL_ID' }
|
102
|
+
|
103
|
+
it 'tracks "ViewContent" event with product data' do
|
104
|
+
subject
|
105
|
+
expect(page).to track_analytics_event :facebook, 'viewcontent', [
|
106
|
+
'fbq', 'track', 'ViewContent', product.name, product.master.sku
|
107
|
+
]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
100
111
|
context 'when PINTEREST_TAG_ID environment variable is present' do
|
101
112
|
let(:env_variable) { 'PINTEREST_TAG_ID' }
|
102
113
|
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Karma Creative
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-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
|
@@ -346,6 +347,7 @@ files:
|
|
346
347
|
- app/views/solidus_seo/_facebook.html.erb
|
347
348
|
- app/views/solidus_seo/_google-analytics.html.erb
|
348
349
|
- app/views/solidus_seo/_google-tag-manager.html.erb
|
350
|
+
- app/views/solidus_seo/_noscript_tags.html.erb
|
349
351
|
- app/views/solidus_seo/_pinterest.html.erb
|
350
352
|
- config/locales/en.yml
|
351
353
|
- config/routes.rb
|
@@ -354,10 +356,12 @@ files:
|
|
354
356
|
- lib/generators/solidus_seo/install/templates/insert_analytics_in_layout.html.erb.deface
|
355
357
|
- lib/generators/solidus_seo/install/templates/insert_display_meta_tags_helper.html.erb.deface
|
356
358
|
- lib/generators/solidus_seo/install/templates/insert_dump_jsonld_helper.html.erb.deface
|
359
|
+
- lib/generators/solidus_seo/install/templates/insert_noscript_tags.html.erb.deface
|
357
360
|
- lib/generators/solidus_seo/install/templates/insert_product_jsonld_helper.html.erb.deface
|
358
361
|
- lib/generators/solidus_seo/install/templates/insert_product_list_helper.html.erb.deface
|
359
362
|
- lib/generators/solidus_seo/install/templates/paperclip_optimizer.rb
|
360
363
|
- lib/generators/solidus_seo/install/templates/remove_original_title_tag.deface
|
364
|
+
- lib/generators/solidus_seo/install/templates/replace_flash_messages_helper.html.erb.deface
|
361
365
|
- lib/generators/solidus_seo/install/templates/replace_taxon_breadcrumbs_helper.html.erb.deface
|
362
366
|
- lib/solidus_seo.rb
|
363
367
|
- lib/solidus_seo/engine.rb
|
@@ -380,6 +384,7 @@ files:
|
|
380
384
|
- spec/examples.txt
|
381
385
|
- spec/features/add_to_cart_spec.rb
|
382
386
|
- spec/features/checkout_complete_spec.rb
|
387
|
+
- spec/features/checkout_initiated_spec.rb
|
383
388
|
- spec/features/homepage_spec.rb
|
384
389
|
- spec/features/product_page_spec.rb
|
385
390
|
- spec/features/taxon_page_spec.rb
|
@@ -390,7 +395,7 @@ homepage: https://github.com/karmakatahdin/solidus_seo
|
|
390
395
|
licenses:
|
391
396
|
- BSD-3-Clause
|
392
397
|
metadata: {}
|
393
|
-
post_install_message:
|
398
|
+
post_install_message:
|
394
399
|
rdoc_options: []
|
395
400
|
require_paths:
|
396
401
|
- lib
|
@@ -405,15 +410,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
405
410
|
- !ruby/object:Gem::Version
|
406
411
|
version: '0'
|
407
412
|
requirements: []
|
408
|
-
rubyforge_project:
|
413
|
+
rubyforge_project:
|
409
414
|
rubygems_version: 2.7.6.2
|
410
|
-
signing_key:
|
415
|
+
signing_key:
|
411
416
|
specification_version: 4
|
412
417
|
summary: Enhanced SEO in Solidus
|
413
418
|
test_files:
|
414
419
|
- spec/spec_helper.rb
|
415
420
|
- spec/examples.txt
|
416
421
|
- spec/features/checkout_complete_spec.rb
|
422
|
+
- spec/features/checkout_initiated_spec.rb
|
417
423
|
- spec/features/homepage_spec.rb
|
418
424
|
- spec/features/taxon_page_spec.rb
|
419
425
|
- spec/features/add_to_cart_spec.rb
|