solidus_seo 1.0.11 → 1.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/views/solidus_seo/_facebook.html.erb +33 -1
- data/lib/generators/solidus_seo/install/install_generator.rb +1 -0
- data/lib/generators/solidus_seo/install/templates/replace_flash_messages_helper.html.erb.deface +5 -0
- data/lib/solidus_seo/version.rb +1 -1
- data/spec/examples.txt +32 -31
- data/spec/features/add_to_cart_spec.rb +14 -0
- data/spec/features/checkout_complete_spec.rb +4 -4
- data/spec/features/product_page_spec.rb +11 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51670eddac384997661e9012323cd72a8d53f93d49798c125a0cdf6090b209de
|
4
|
+
data.tar.gz: 0672d2f46cf997f24e6b9c9ded5943af3bf86fc7b2c50c30f4c79a363052b870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74fc866d03e824e4d02a0cf9f6ea398934b8f718ff07da6e8da08d6b124f46f1c1167d611f2f0c9dd31f5d03a23dd1db16965d1bc4e209dd612e67fad543be5b
|
7
|
+
data.tar.gz: 4f3b5e18a483447b87cd2cfe4771033e0d02e99fc873973760faeec526369b4dca0f1d2e97faabb2a4e5884eba31b0bc718b8f95ddedb3f6d094267cfba62099
|
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.
|
@@ -1,6 +1,10 @@
|
|
1
1
|
<%
|
2
2
|
return if ENV['FACEBOOK_PIXEL_ID'].blank?
|
3
3
|
|
4
|
+
product_data = {}
|
5
|
+
add_to_cart_data = {}
|
6
|
+
order_data = {}
|
7
|
+
|
4
8
|
if just_purchased
|
5
9
|
order_data = {
|
6
10
|
value: order.total,
|
@@ -20,6 +24,24 @@ if just_purchased
|
|
20
24
|
promo_total: order.promo_total
|
21
25
|
}
|
22
26
|
end
|
27
|
+
|
28
|
+
if flash[:added_to_cart].present?
|
29
|
+
add_to_cart_data = {
|
30
|
+
currency: order.currency,
|
31
|
+
content_type: 'product',
|
32
|
+
contents: flash[:added_to_cart].map do |variant_sku, variant|
|
33
|
+
{ id: variant_sku, quantity: variant['quantity'] }
|
34
|
+
end
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
if @product
|
39
|
+
product_data = {
|
40
|
+
content_type: 'product',
|
41
|
+
content_name: @product.name,
|
42
|
+
content_ids: [@product.master.sku]
|
43
|
+
}
|
44
|
+
end
|
23
45
|
%>
|
24
46
|
<script type="text/javascript" data-tag="facebook">
|
25
47
|
!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 +49,20 @@ end
|
|
27
49
|
fbq('init', '<%= ENV['FACEBOOK_PIXEL_ID'] %>');
|
28
50
|
fbq('track', 'PageView');
|
29
51
|
|
30
|
-
<% if
|
52
|
+
<% if order_data.present? %>
|
31
53
|
fbq('track', 'Purchase', <%== order_data.to_json %>);
|
32
54
|
window.solidusSeoDataLayer('facebook', 'purchase');
|
33
55
|
<% end %>
|
56
|
+
|
57
|
+
<% if add_to_cart_data.present? %>
|
58
|
+
fbq('track', 'AddToCart', <%== add_to_cart_data.to_json %>);
|
59
|
+
window.solidusSeoDataLayer('facebook', 'addtocart');
|
60
|
+
<% end %>
|
61
|
+
|
62
|
+
<% if product_data.present? %>
|
63
|
+
fbq('track', 'ViewContent', <%== product_data.to_json %>);
|
64
|
+
window.solidusSeoDataLayer('facebook', 'productview');
|
65
|
+
<% end %>
|
34
66
|
</script>
|
35
67
|
<noscript>
|
36
68
|
<img height="1" width="1" src="https://www.facebook.com/tr?id=<%= ENV['FACEBOOK_PIXEL_ID'] %>&ev=PageView&noscript=1" />
|
@@ -36,6 +36,7 @@ module SolidusSeo
|
|
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
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'
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
data/lib/solidus_seo/version.rb
CHANGED
data/spec/examples.txt
CHANGED
@@ -1,33 +1,34 @@
|
|
1
1
|
example_id | status | run_time |
|
2
2
|
------------------------------------------------ | ------ | --------------- |
|
3
|
-
./spec/features/add_to_cart_spec.rb[1:1:1] | passed |
|
4
|
-
./spec/features/
|
5
|
-
./spec/features/checkout_complete_spec.rb[1:
|
6
|
-
./spec/features/checkout_complete_spec.rb[1:
|
7
|
-
./spec/features/checkout_complete_spec.rb[1:
|
8
|
-
./spec/features/
|
9
|
-
./spec/features/homepage_spec.rb[1:1:
|
10
|
-
./spec/features/homepage_spec.rb[1:2
|
11
|
-
./spec/features/homepage_spec.rb[1:2:
|
12
|
-
./spec/features/homepage_spec.rb[1:
|
13
|
-
./spec/features/homepage_spec.rb[1:3:
|
14
|
-
./spec/features/homepage_spec.rb[1:
|
15
|
-
./spec/features/
|
16
|
-
./spec/features/product_page_spec.rb[1:1:
|
17
|
-
./spec/features/product_page_spec.rb[1:1:
|
18
|
-
./spec/features/product_page_spec.rb[1:
|
19
|
-
./spec/features/product_page_spec.rb[1:2:
|
20
|
-
./spec/features/product_page_spec.rb[1:2:
|
21
|
-
./spec/features/product_page_spec.rb[1:3:1]
|
22
|
-
./spec/features/product_page_spec.rb[1:3:
|
23
|
-
./spec/features/product_page_spec.rb[1:3:
|
24
|
-
./spec/features/product_page_spec.rb[1:
|
25
|
-
./spec/features/
|
26
|
-
./spec/features/taxon_page_spec.rb[1:1:
|
27
|
-
./spec/features/taxon_page_spec.rb[1:1:
|
28
|
-
./spec/features/taxon_page_spec.rb[1:
|
29
|
-
./spec/features/taxon_page_spec.rb[1:2:
|
30
|
-
./spec/features/taxon_page_spec.rb[1:2:
|
31
|
-
./spec/features/taxon_page_spec.rb[1:3:1]
|
32
|
-
./spec/features/taxon_page_spec.rb[1:3:
|
33
|
-
./spec/features/taxon_page_spec.rb[1:
|
3
|
+
./spec/features/add_to_cart_spec.rb[1:1:1] | passed | 1.07 seconds |
|
4
|
+
./spec/features/add_to_cart_spec.rb[1:1:2] | passed | 1.37 seconds |
|
5
|
+
./spec/features/checkout_complete_spec.rb[1:1:1] | passed | 0.53998 seconds |
|
6
|
+
./spec/features/checkout_complete_spec.rb[1:2:1] | passed | 2.38 seconds |
|
7
|
+
./spec/features/checkout_complete_spec.rb[1:3:1] | passed | 0.84872 seconds |
|
8
|
+
./spec/features/checkout_complete_spec.rb[1:4:1] | passed | 1.24 seconds |
|
9
|
+
./spec/features/homepage_spec.rb[1:1:1] | passed | 0.24724 seconds |
|
10
|
+
./spec/features/homepage_spec.rb[1:1:2] | passed | 2.97 seconds |
|
11
|
+
./spec/features/homepage_spec.rb[1:2:1] | passed | 0.2808 seconds |
|
12
|
+
./spec/features/homepage_spec.rb[1:2:2] | passed | 0.29667 seconds |
|
13
|
+
./spec/features/homepage_spec.rb[1:3:1] | passed | 0.30094 seconds |
|
14
|
+
./spec/features/homepage_spec.rb[1:3:2] | passed | 0.31454 seconds |
|
15
|
+
./spec/features/homepage_spec.rb[1:4:1:1] | passed | 0.92066 seconds |
|
16
|
+
./spec/features/product_page_spec.rb[1:1:1] | passed | 0.46804 seconds |
|
17
|
+
./spec/features/product_page_spec.rb[1:1:2] | passed | 0.58854 seconds |
|
18
|
+
./spec/features/product_page_spec.rb[1:1:3] | passed | 0.44073 seconds |
|
19
|
+
./spec/features/product_page_spec.rb[1:2:1] | passed | 0.48328 seconds |
|
20
|
+
./spec/features/product_page_spec.rb[1:2:2:1] | passed | 0.52483 seconds |
|
21
|
+
./spec/features/product_page_spec.rb[1:2:3:1] | passed | 0.48305 seconds |
|
22
|
+
./spec/features/product_page_spec.rb[1:3:1] | passed | 0.40406 seconds |
|
23
|
+
./spec/features/product_page_spec.rb[1:3:2] | passed | 0.44702 seconds |
|
24
|
+
./spec/features/product_page_spec.rb[1:3:3] | passed | 0.40842 seconds |
|
25
|
+
./spec/features/product_page_spec.rb[1:4:1:1] | passed | 0.38661 seconds |
|
26
|
+
./spec/features/taxon_page_spec.rb[1:1:1] | passed | 0.36011 seconds |
|
27
|
+
./spec/features/taxon_page_spec.rb[1:1:2] | passed | 0.49162 seconds |
|
28
|
+
./spec/features/taxon_page_spec.rb[1:1:3] | passed | 0.52362 seconds |
|
29
|
+
./spec/features/taxon_page_spec.rb[1:2:1] | passed | 0.49447 seconds |
|
30
|
+
./spec/features/taxon_page_spec.rb[1:2:2:1] | passed | 0.46672 seconds |
|
31
|
+
./spec/features/taxon_page_spec.rb[1:2:3:1] | passed | 0.43612 seconds |
|
32
|
+
./spec/features/taxon_page_spec.rb[1:3:1] | passed | 0.38696 seconds |
|
33
|
+
./spec/features/taxon_page_spec.rb[1:3:2] | passed | 0.47861 seconds |
|
34
|
+
./spec/features/taxon_page_spec.rb[1:4:1] | passed | 0.74015 seconds |
|
@@ -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
|
|
@@ -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
|
@@ -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, 'productview', [
|
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.0.12
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -360,6 +360,7 @@ files:
|
|
360
360
|
- lib/generators/solidus_seo/install/templates/insert_product_list_helper.html.erb.deface
|
361
361
|
- lib/generators/solidus_seo/install/templates/paperclip_optimizer.rb
|
362
362
|
- lib/generators/solidus_seo/install/templates/remove_original_title_tag.deface
|
363
|
+
- lib/generators/solidus_seo/install/templates/replace_flash_messages_helper.html.erb.deface
|
363
364
|
- lib/generators/solidus_seo/install/templates/replace_taxon_breadcrumbs_helper.html.erb.deface
|
364
365
|
- lib/solidus_seo.rb
|
365
366
|
- lib/solidus_seo/engine.rb
|
@@ -392,7 +393,7 @@ homepage: https://github.com/karmakatahdin/solidus_seo
|
|
392
393
|
licenses:
|
393
394
|
- BSD-3-Clause
|
394
395
|
metadata: {}
|
395
|
-
post_install_message:
|
396
|
+
post_install_message:
|
396
397
|
rdoc_options: []
|
397
398
|
require_paths:
|
398
399
|
- lib
|
@@ -407,9 +408,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
407
408
|
- !ruby/object:Gem::Version
|
408
409
|
version: '0'
|
409
410
|
requirements: []
|
410
|
-
rubyforge_project:
|
411
|
+
rubyforge_project:
|
411
412
|
rubygems_version: 2.7.6.2
|
412
|
-
signing_key:
|
413
|
+
signing_key:
|
413
414
|
specification_version: 4
|
414
415
|
summary: Enhanced SEO in Solidus
|
415
416
|
test_files:
|