solidus_seo 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/decorators/models/spree/product_decorator.rb +2 -2
- data/app/views/solidus_seo/_google-analytics.html.erb +12 -11
- data/app/views/solidus_seo/_google-tag-manager.html.erb +37 -36
- data/app/views/solidus_seo/_noscript_tags.html.erb +7 -0
- data/lib/generators/solidus_seo/install/install_generator.rb +1 -0
- data/lib/generators/solidus_seo/install/templates/insert_noscript_tags.html.erb.deface +4 -0
- data/lib/solidus_seo/jsonld/tag_helper.rb +1 -1
- data/lib/solidus_seo/version.rb +1 -1
- data/spec/examples.txt +31 -30
- data/spec/features/homepage_spec.rb +15 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b59bc10f88b145907a907757d59bfa0ddfc1991e7e20313bb4b2b7bb522935f
|
4
|
+
data.tar.gz: 879ddd7cbc5884f6eefcfd027d266e8a8c17a707f9312cdf6367970bc9c47d33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2f9462a55c124cc5eb2871a8fcdf5c0215bf7fc6280c50295da392f12169c4b2c93a9ca5a13f77291beb4a481fd7de38fb4c25b407e68b83614aab9efa5bbd9
|
7
|
+
data.tar.gz: 41787840fd2c469c0103a2f76b53b93586a4c09febbabb9ff82ca1845dfa8c8ed7b035e386e53b2e0cb903873824cd119510784a1a5da53429fb2ae6e088e495
|
@@ -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
|
|
@@ -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
|
-
|
28
|
+
<script>
|
29
|
+
window.dataLayer = window.dataLayer || [];
|
30
|
+
function gtag(){dataLayer.push(arguments);}
|
31
|
+
gtag('js', new Date());
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
gtag('js', new Date());
|
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', <%== order_data.to_json %>);
|
39
|
+
window.solidusSeoDataLayer('google-analytics', 'purchase');
|
40
|
+
</script>
|
41
|
+
<% end %>
|
@@ -2,49 +2,50 @@
|
|
2
2
|
return if ENV['GOOGLE_ANALYTICS_ID'].present? || ENV['GOOGLE_TAG_MANAGER_ID'].blank?
|
3
3
|
|
4
4
|
if just_purchased
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
order_data = {
|
6
|
+
id: order.number,
|
7
|
+
revenue: order.total,
|
8
|
+
coupon: '', # TODO: Add coupon code if present
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
affiliation: current_store.name,
|
11
|
+
currency: order.currency,
|
12
|
+
tax: order.tax_total,
|
13
|
+
shipping: order.ship_total
|
14
|
+
}
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
purchased_items = order.line_items.map do |line_item|
|
17
|
+
next unless line_item.variant
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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.compact
|
27
27
|
end
|
28
28
|
%>
|
29
29
|
<script type="text/javascript" data-tag="google-tag-manager">
|
30
|
-
|
30
|
+
window.dataLayer = window.dataLayer || [];
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
window.solidusSeoDataLayer('google-tag-manager', 'purchase');
|
43
|
-
<% end %>
|
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
|
+
});
|
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) -->
|
@@ -35,6 +35,7 @@ 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'
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
data/lib/solidus_seo/version.rb
CHANGED
data/spec/examples.txt
CHANGED
@@ -1,32 +1,33 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
------------------------------------------------ | ------ | --------------- |
|
3
|
-
./spec/features/add_to_cart_spec.rb[1:1:1] | passed |
|
4
|
-
./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 0.
|
5
|
-
./spec/features/checkout_complete_spec.rb[1:2:1] | passed |
|
6
|
-
./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.
|
7
|
-
./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 0.
|
8
|
-
./spec/features/homepage_spec.rb[1:1:1] | passed | 0.
|
9
|
-
./spec/features/homepage_spec.rb[1:1:2] | passed | 0.
|
10
|
-
./spec/features/homepage_spec.rb[1:2:1] | passed | 0.
|
11
|
-
./spec/features/homepage_spec.rb[1:2:2] | passed | 0.
|
12
|
-
./spec/features/homepage_spec.rb[1:3:1] | passed | 0.
|
13
|
-
./spec/features/homepage_spec.rb[1:3:2] | passed | 0.
|
14
|
-
./spec/features/
|
15
|
-
./spec/features/product_page_spec.rb[1:1:
|
16
|
-
./spec/features/product_page_spec.rb[1:1:
|
17
|
-
./spec/features/product_page_spec.rb[1:
|
18
|
-
./spec/features/product_page_spec.rb[1:2:
|
19
|
-
./spec/features/product_page_spec.rb[1:2:
|
20
|
-
./spec/features/product_page_spec.rb[1:3:1]
|
21
|
-
./spec/features/product_page_spec.rb[1:3:
|
22
|
-
./spec/features/product_page_spec.rb[1:3:
|
23
|
-
./spec/features/product_page_spec.rb[1:
|
24
|
-
./spec/features/
|
25
|
-
./spec/features/taxon_page_spec.rb[1:1:
|
26
|
-
./spec/features/taxon_page_spec.rb[1:1:
|
27
|
-
./spec/features/taxon_page_spec.rb[1:
|
28
|
-
./spec/features/taxon_page_spec.rb[1:2:
|
29
|
-
./spec/features/taxon_page_spec.rb[1:2:
|
30
|
-
./spec/features/taxon_page_spec.rb[1:3:1]
|
31
|
-
./spec/features/taxon_page_spec.rb[1:3:
|
32
|
-
./spec/features/taxon_page_spec.rb[1:
|
3
|
+
./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 2.14 seconds |
|
4
|
+
./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 0.59035 seconds |
|
5
|
+
./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 0.70409 seconds |
|
6
|
+
./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.77986 seconds |
|
7
|
+
./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 0.53269 seconds |
|
8
|
+
./spec/features/homepage_spec.rb[1:1:1] | passed | 0.27083 seconds |
|
9
|
+
./spec/features/homepage_spec.rb[1:1:2] | passed | 0.2846 seconds |
|
10
|
+
./spec/features/homepage_spec.rb[1:2:1] | passed | 0.26788 seconds |
|
11
|
+
./spec/features/homepage_spec.rb[1:2:2] | passed | 0.26357 seconds |
|
12
|
+
./spec/features/homepage_spec.rb[1:3:1] | passed | 0.2807 seconds |
|
13
|
+
./spec/features/homepage_spec.rb[1:3:2] | passed | 0.28623 seconds |
|
14
|
+
./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.55629 seconds |
|
15
|
+
./spec/features/product_page_spec.rb[1:1:1] | passed | 0.44472 seconds |
|
16
|
+
./spec/features/product_page_spec.rb[1:1:2] | passed | 0.37428 seconds |
|
17
|
+
./spec/features/product_page_spec.rb[1:1:3] | passed | 0.48305 seconds |
|
18
|
+
./spec/features/product_page_spec.rb[1:2:1] | passed | 0.37207 seconds |
|
19
|
+
./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.33481 seconds |
|
20
|
+
./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.35463 seconds |
|
21
|
+
./spec/features/product_page_spec.rb[1:3:1] | passed | 0.40858 seconds |
|
22
|
+
./spec/features/product_page_spec.rb[1:3:2] | passed | 0.39049 seconds |
|
23
|
+
./spec/features/product_page_spec.rb[1:3:3] | passed | 0.43994 seconds |
|
24
|
+
./spec/features/product_page_spec.rb[1:4:1:1] | passed | 4.3 seconds |
|
25
|
+
./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.40068 seconds |
|
26
|
+
./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.39674 seconds |
|
27
|
+
./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.36863 seconds |
|
28
|
+
./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.46435 seconds |
|
29
|
+
./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.38776 seconds |
|
30
|
+
./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.36313 seconds |
|
31
|
+
./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.39374 seconds |
|
32
|
+
./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.36606 seconds |
|
33
|
+
./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.585 seconds |
|
@@ -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
|
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.0.11
|
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-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -346,6 +346,7 @@ files:
|
|
346
346
|
- app/views/solidus_seo/_facebook.html.erb
|
347
347
|
- app/views/solidus_seo/_google-analytics.html.erb
|
348
348
|
- app/views/solidus_seo/_google-tag-manager.html.erb
|
349
|
+
- app/views/solidus_seo/_noscript_tags.html.erb
|
349
350
|
- app/views/solidus_seo/_pinterest.html.erb
|
350
351
|
- config/locales/en.yml
|
351
352
|
- config/routes.rb
|
@@ -354,6 +355,7 @@ files:
|
|
354
355
|
- lib/generators/solidus_seo/install/templates/insert_analytics_in_layout.html.erb.deface
|
355
356
|
- lib/generators/solidus_seo/install/templates/insert_display_meta_tags_helper.html.erb.deface
|
356
357
|
- lib/generators/solidus_seo/install/templates/insert_dump_jsonld_helper.html.erb.deface
|
358
|
+
- lib/generators/solidus_seo/install/templates/insert_noscript_tags.html.erb.deface
|
357
359
|
- lib/generators/solidus_seo/install/templates/insert_product_jsonld_helper.html.erb.deface
|
358
360
|
- lib/generators/solidus_seo/install/templates/insert_product_list_helper.html.erb.deface
|
359
361
|
- lib/generators/solidus_seo/install/templates/paperclip_optimizer.rb
|