spree_analytics_trackers 1.0.1 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bundle/config +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +30 -15
- data/Appraisals +3 -9
- data/LICENSE +1 -1
- data/README.md +7 -3
- data/app/assets/javascripts/spree/frontend/add_to_cart_analytics.js +50 -0
- data/app/assets/javascripts/spree/frontend/remove_from_cart_analytics.js +34 -0
- data/app/controllers/spree/admin/trackers_controller.rb +8 -0
- data/app/controllers/spree_analytics_trackers/checkout_controller_decorator.rb +11 -0
- data/app/controllers/spree_analytics_trackers/store_controller_decorator.rb +13 -0
- data/app/controllers/spree_analytics_trackers/user_confirmations_controller_decorator.rb +11 -0
- data/app/controllers/spree_analytics_trackers/user_passwords_controller_decorator.rb +11 -0
- data/app/controllers/spree_analytics_trackers/user_registrations_controller_decorator.rb +11 -0
- data/app/controllers/spree_analytics_trackers/user_sessions_controller_decorator.rb +11 -0
- data/app/helpers/spree/trackers_helper.rb +79 -16
- data/app/models/spree/tracker.rb +11 -5
- data/app/models/spree_analytics_trackers/user_decorator.rb +9 -0
- data/app/overrides/add_analytics_to_admin_sidebar.rb +2 -3
- data/app/overrides/add_cart_viewed_to_orders_edit.rb +1 -1
- data/app/overrides/add_checkout_step_viewed_to_checkout_edit.rb +11 -3
- data/app/overrides/add_google_analytics_page_view_to_spree_application.rb +10 -0
- data/app/overrides/add_google_analytics_to_spree_application.rb +4 -4
- data/app/overrides/add_google_purchase_to_orders_show.rb +1 -1
- data/app/overrides/add_product_list_filtered_to_taxons_show.rb +1 -1
- data/app/overrides/add_product_list_viewed_to_products_list.rb +1 -1
- data/app/overrides/add_product_viewed_to_products_show.rb +2 -2
- data/app/overrides/add_products_searched_to_products_list.rb +2 -2
- data/app/overrides/add_segment_initializer_to_layout.rb +3 -3
- data/app/overrides/add_segment_page_viewed_to_layout.rb +10 -0
- data/app/presenters/spree_analytics_trackers/base_presenter.rb +14 -0
- data/app/presenters/spree_analytics_trackers/segment/order_presenter.rb +32 -0
- data/app/presenters/spree_analytics_trackers/segment/product_presenter.rb +40 -0
- data/app/views/spree/admin/shared/_analytics_sidebar_menu.html.erb +3 -5
- data/app/views/spree/admin/trackers/_form.html.erb +13 -7
- data/app/views/spree/admin/trackers/index.html.erb +6 -8
- data/app/views/spree/shared/trackers/google_analytics/_checkout_step_viewed.js.erb +19 -0
- data/app/views/spree/shared/trackers/google_analytics/_initializer.js.erb +25 -0
- data/app/views/spree/shared/trackers/google_analytics/_page_viewed.js.erb +13 -0
- data/app/views/spree/shared/trackers/google_analytics/_purchase.js.erb +22 -0
- data/app/views/spree/shared/trackers/segment/_cart_viewed.js.erb +24 -19
- data/app/views/spree/shared/trackers/segment/_checkout_step_viewed.js.erb +20 -11
- data/app/views/spree/shared/trackers/segment/_initializer.js.erb +2 -3
- data/app/views/spree/shared/trackers/segment/_order_complete.js.erb +8 -45
- data/app/views/spree/shared/trackers/segment/_page_viewed.js.erb +7 -0
- data/app/views/spree/shared/trackers/segment/_product_list_filtered.js.erb +19 -28
- data/app/views/spree/shared/trackers/segment/_product_list_viewed.js.erb +17 -20
- data/app/views/spree/shared/trackers/segment/_product_viewed.js.erb +12 -6
- data/app/views/spree/shared/trackers/segment/_products_searched.js.erb +7 -9
- data/config/locales/en.yml +0 -2
- data/config/locales/zh-TW.yml +19 -0
- data/db/migrate/20200721163729_add_store_id_to_spree_trackers.rb +14 -0
- data/gemfiles/{spree_3_5.gemfile → spree_4_1.gemfile} +2 -2
- data/gemfiles/spree_master.gemfile +0 -1
- data/lib/generators/spree_analytics_trackers/install/install_generator.rb +8 -0
- data/lib/spree_analytics_trackers.rb +1 -0
- data/lib/spree_analytics_trackers/factories.rb +1 -0
- data/lib/spree_analytics_trackers/version.rb +3 -9
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +18 -7
- data/spec/features/checkout_spec.rb +15 -0
- data/spec/features/products_spec.rb +315 -0
- data/spec/features/user_login_spec.rb +7 -0
- data/spec/features/user_password_recovery_spec.rb +7 -0
- data/spec/features/user_registration_spec.rb +7 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/models/spree/tracker_spec.rb +15 -0
- data/spec/presenters/spree_analytics_trackers/segment/order_presenter_spec.rb +34 -0
- data/spec/spec_helper.rb +7 -82
- data/spec/support/custom_products.rb +26 -0
- data/spree_analytics_trackers.gemspec +4 -17
- metadata +56 -212
- data/app/controllers/spree/store_controller_decorator.rb +0 -5
- data/app/models/spree/line_item_decorator.rb +0 -6
- data/app/models/spree/order_decorator.rb +0 -7
- data/app/models/spree/product_decorator.rb +0 -11
- data/app/models/spree/user_decorator.rb +0 -5
- data/app/overrides/add_google_checkout_to_checkout_edit.rb +0 -9
- data/app/overrides/add_product_added_to_orders_edit.rb +0 -10
- data/app/views/spree/shared/_google_add_items.html.erb +0 -13
- data/app/views/spree/shared/_google_analytics.html.erb +0 -18
- data/app/views/spree/shared/_google_checkout.html.erb +0 -14
- data/app/views/spree/shared/_google_purchase.html.erb +0 -19
- data/app/views/spree/shared/trackers/segment/_product_added.js.erb +0 -9
- data/gemfiles/spree_3_7.gemfile +0 -9
@@ -1,11 +0,0 @@
|
|
1
|
-
if Gem.loaded_specs['spree_core'].version < Gem::Version.create('3.2.0')
|
2
|
-
Spree::Product.class_eval do
|
3
|
-
def category
|
4
|
-
taxons.joins(:taxonomy).find_by(spree_taxonomies: { name: Spree.t(:taxonomy_categories_name) })
|
5
|
-
end
|
6
|
-
|
7
|
-
def brand
|
8
|
-
taxons.joins(:taxonomy).find_by(spree_taxonomies: { name: Spree.t(:taxonomy_brands_name) })
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
if Gem.loaded_specs['spree_core'].version >= Gem::Version.create('3.5.0')
|
2
|
-
Deface::Override.new(
|
3
|
-
virtual_path: 'spree/checkout/edit',
|
4
|
-
name: 'add_google_checkout_to_checkout_edit',
|
5
|
-
insert_before: "#checkout",
|
6
|
-
partial: 'spree/shared/google_checkout',
|
7
|
-
original: '1bc9409097210501fee61bc448df937682546308'
|
8
|
-
)
|
9
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
spree_version = Gem.loaded_specs['spree_core'].version
|
2
|
-
unless spree_version >= Gem::Version.create('3.4.0') && spree_version < Gem::Version.create('3.5.0')
|
3
|
-
Deface::Override.new(
|
4
|
-
virtual_path: 'spree/orders/edit',
|
5
|
-
name: 'add_product_added_to_orders_edit',
|
6
|
-
insert_top: "[data-hook='cart_container']",
|
7
|
-
partial: 'spree/shared/trackers/segment/product_added.js',
|
8
|
-
original: '75a9171ce7647353a00bdfa178b131872e7f9bdc'
|
9
|
-
)
|
10
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
if (typeof ga !== 'undefined') {
|
2
|
-
<% @order.line_items.each do |line_item| %>
|
3
|
-
ga('ec:addProduct', { // Provide product details in a productFieldObject.
|
4
|
-
'id': '<%= j (line_item.sku.present? ? line_item.sku : line_item.variant_id.to_s) %>', // Product ID (string).
|
5
|
-
'name': '<%= j line_item.name %>', // Product name (string).
|
6
|
-
'category': '<%= j line_item.category.try(:name) %>', // Product category (string).
|
7
|
-
'brand': '<%= j line_item.brand.try(:name) %>', // Product brand (string).
|
8
|
-
'variant': '<%= j line_item.options_text %>', // Product variant (string).
|
9
|
-
'price': '<%= line_item.price %>',
|
10
|
-
'quantity': <%= line_item.quantity %>
|
11
|
-
});
|
12
|
-
<% end %>
|
13
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
<% if tracker = Spree::Tracker.current(:google_analytics) %>
|
2
|
-
<script>
|
3
|
-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
4
|
-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
5
|
-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
6
|
-
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
7
|
-
|
8
|
-
<% if user_analytics_id = try_spree_current_user.try(:analytics_id) %>
|
9
|
-
ga('create', { 'trackingId': '<%= tracker.analytics_id %>', 'cookieDomain': 'auto', 'userId': '<%= user_analytics_id %>' });
|
10
|
-
<% else %>
|
11
|
-
ga('create', '<%= tracker.analytics_id %>', 'auto');
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
ga('require', 'displayfeatures');
|
15
|
-
<%= yield :google_analytics %>
|
16
|
-
ga('send', 'pageview');
|
17
|
-
</script>
|
18
|
-
<% end %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<%# more info: https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce %>
|
2
|
-
<script>
|
3
|
-
if (typeof ga !== 'undefined') {
|
4
|
-
ga('require', 'ec');
|
5
|
-
ga('set', '&cu', '<%= current_currency %>');
|
6
|
-
|
7
|
-
<%= render partial: 'spree/shared/google_add_items', locals: { order: @order } %>
|
8
|
-
|
9
|
-
// Add the step number and additional info about the checkout to the action.
|
10
|
-
ga('ec:setAction','checkout', {
|
11
|
-
'step': <%= (@order.checkout_steps.index(@order.state) + 1) %>
|
12
|
-
});
|
13
|
-
}
|
14
|
-
</script>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<% if order_just_completed?(@order) %>
|
2
|
-
<script>
|
3
|
-
<%# more info: https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce %>
|
4
|
-
if (typeof ga !== 'undefined') {
|
5
|
-
ga('require', 'ec');
|
6
|
-
ga('set', '&cu', '<%= current_currency %>');
|
7
|
-
|
8
|
-
<%= render partial: 'spree/shared/google_add_items', locals: { order: @order } %>
|
9
|
-
|
10
|
-
ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject.
|
11
|
-
'id': '<%= j @order.number %>', // Transaction ID. Required.
|
12
|
-
'affiliation': '<%= current_store.name %>', // Affiliation (string).
|
13
|
-
'revenue': '<%= @order.total %>', // Revenue (currency).
|
14
|
-
'tax': '<%= @order.tax_total %>', // Tax.
|
15
|
-
'shipping': '<%= @order.ship_total %>' // Shipping.
|
16
|
-
});
|
17
|
-
}
|
18
|
-
</script>
|
19
|
-
<% end %>
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<% if @variant %>
|
2
|
-
<script>
|
3
|
-
if (typeof analytics !== 'undefined') {
|
4
|
-
analytics.track('Product Added', <%= product_for_segment(@variant.product, cart_id: @order.number) %>);
|
5
|
-
analytics.page('Product Added', <%= product_for_segment(@variant.product, cart_id: @order.number) %>);
|
6
|
-
|
7
|
-
}
|
8
|
-
</script>
|
9
|
-
<% end %>
|