caboose-cms 0.5.219 → 0.5.220
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 +8 -8
- data/app/controllers/caboose/application_controller.rb +10 -1
- data/app/controllers/caboose/cart_controller.rb +5 -3
- data/app/controllers/caboose/checkout_controller.rb +7 -2
- data/app/controllers/caboose/products_controller.rb +5 -2
- data/app/controllers/caboose/social_controller.rb +1 -0
- data/app/models/caboose/ga.rb +29 -0
- data/app/models/caboose/schema.rb +2 -1
- data/app/views/caboose/blocks/_ga.html.erb +27 -0
- data/app/views/caboose/blocks/_ga_events.html.erb +16 -0
- data/app/views/caboose/social/admin_edit.html.erb +12 -10
- data/app/views/layouts/caboose/application.html.erb +5 -2
- data/lib/caboose/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDYxYWNkYjFmNGQ2NTAwZmY1Yjg5ZmQ1M2JiMzlkMTRmMWYwZmUwMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjgyYWMwMTAxMTJlZGZkNGI5MGU4YzM1ZDgwMGNhY2M1OTE1NzM0Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTYxMzdhMzUxNTA4ZjhhZjk4Y2I3ZWQ4ZWU2ZTliZDkzYjAzODM0YzU2ZWI5
|
10
|
+
NzJlYjJlOGQwOTdhYmFlNTYzNjEwM2M0ZGI1ZmZkYzJlMjIyODM1MWZkYzIz
|
11
|
+
NGE0MWVhNWRkMjhmY2IzMzM0ODAyZTQ2MDhkOGI4MzdjZTAyN2M=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGJiMjFiNTc3NGQ3ZmQxMzBjZDhmNDA0OGY1ODBmOTFjYjFlZDNkODhlY2Fm
|
14
|
+
MmNjZmQxMzkxNTNjNzVjOGY0NWZlM2U3YzdlMTkyMmZjYTFhYTkyOWNkYTli
|
15
|
+
OTY5NDVmMTUyZTA5MjgwNjllNWMxNTU5YTZmNGJlM2NlOTFlYzE=
|
@@ -13,7 +13,7 @@ module Caboose
|
|
13
13
|
parse_url_params if Caboose.use_url_params
|
14
14
|
|
15
15
|
@use_page_cache = !request.fullpath.starts_with?('/admin')
|
16
|
-
|
16
|
+
|
17
17
|
# Get the site we're working with
|
18
18
|
domain = Domain.where(:domain => request.host_with_port).first
|
19
19
|
@site = domain ? domain.site : nil
|
@@ -38,6 +38,7 @@ module Caboose
|
|
38
38
|
@tasks = {}
|
39
39
|
@page_tasks = {}
|
40
40
|
@is_real_page = false
|
41
|
+
@ga_events = []
|
41
42
|
|
42
43
|
#if @find_page
|
43
44
|
@page = Page.page_with_uri(request.host_with_port, request.fullpath)
|
@@ -79,6 +80,14 @@ module Caboose
|
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
83
|
+
def add_ga_event(cat, action, label = nil, value = nil)
|
84
|
+
# Category String Required Typically the object that was interacted with (e.g. button)
|
85
|
+
# Action String Required The type of interaction (e.g. click)
|
86
|
+
# Label String Option Useful for categorizing events (e.g. nav buttons)
|
87
|
+
# Value Number Option Values must be non-negative. Useful to pass counts (e.g. 4 times)
|
88
|
+
@ga_events << [cat, action, label, value]
|
89
|
+
end
|
90
|
+
|
82
91
|
# Parses any parameters in the URL and adds them to the params
|
83
92
|
def parse_url_params
|
84
93
|
return if !Caboose.use_url_params
|
@@ -34,7 +34,7 @@ module Caboose
|
|
34
34
|
|
35
35
|
# GET /cart/item-count
|
36
36
|
def item_count
|
37
|
-
render :json => { :item_count => @order.item_count }
|
37
|
+
render :json => { :item_count => @order.item_count }
|
38
38
|
end
|
39
39
|
|
40
40
|
# POST /cart
|
@@ -56,12 +56,13 @@ module Caboose
|
|
56
56
|
:subtotal => unit_price * qty,
|
57
57
|
:status => 'pending'
|
58
58
|
)
|
59
|
-
end
|
59
|
+
end
|
60
|
+
GA.delay.event(@site.id, 'cart', 'add', "Product #{v.product.id}, Variant #{v.id}")
|
60
61
|
render :json => {
|
61
62
|
:success => li.save,
|
62
63
|
:errors => li.errors.full_messages,
|
63
64
|
:item_count => @order.item_count
|
64
|
-
}
|
65
|
+
}
|
65
66
|
end
|
66
67
|
|
67
68
|
# PUT /cart/:line_item_id
|
@@ -126,6 +127,7 @@ module Caboose
|
|
126
127
|
@order.calculate
|
127
128
|
resp.success = true
|
128
129
|
resp.order_total = @order.total
|
130
|
+
GA.delay.event(@site.id, 'giftcard', 'add', "Giftcard #{gc.id}")
|
129
131
|
end
|
130
132
|
render :json => resp
|
131
133
|
end
|
@@ -55,7 +55,9 @@ module Caboose
|
|
55
55
|
Caboose.log(@rates)
|
56
56
|
|
57
57
|
#Caboose.log(@rates.inspect)
|
58
|
-
@logged_in_user = logged_in_user
|
58
|
+
@logged_in_user = logged_in_user
|
59
|
+
|
60
|
+
add_ga_event('checkout', 'shipping')
|
59
61
|
end
|
60
62
|
|
61
63
|
# Step 4 - Gift cards
|
@@ -65,6 +67,7 @@ module Caboose
|
|
65
67
|
redirect_to '/checkout/addresses' and return if @order.billing_address.nil? || (@order.has_shippable_items? && @order.shipping_address.nil?)
|
66
68
|
redirect_to '/checkout/shipping' and return if @order.has_shippable_items? && @order.has_empty_shipping_methods?
|
67
69
|
@logged_in_user = logged_in_user
|
70
|
+
add_ga_event('checkout', 'gift-cards')
|
68
71
|
end
|
69
72
|
|
70
73
|
# Step 5 - Payment
|
@@ -107,6 +110,7 @@ module Caboose
|
|
107
110
|
@form_url = Caboose::PaymentProcessor.form_url(@order)
|
108
111
|
end
|
109
112
|
@logged_in_user = logged_in_user
|
113
|
+
add_ga_event('checkout', 'payment')
|
110
114
|
end
|
111
115
|
|
112
116
|
# GET /checkout/confirm
|
@@ -125,6 +129,7 @@ module Caboose
|
|
125
129
|
end
|
126
130
|
end
|
127
131
|
@logged_in_user = logged_in_user
|
132
|
+
add_ga_event('checkout', 'confirm_without_payment')
|
128
133
|
end
|
129
134
|
|
130
135
|
# POST /checkout/confirm
|
@@ -171,7 +176,7 @@ module Caboose
|
|
171
176
|
|
172
177
|
# Find the last order for the user
|
173
178
|
@last_order = Order.where(:customer_id => @logged_in_user.id).order("id desc").limit(1).first
|
174
|
-
|
179
|
+
add_ga_event('checkout', 'thanks')
|
175
180
|
end
|
176
181
|
|
177
182
|
#===========================================================================
|
@@ -27,6 +27,7 @@ module Caboose
|
|
27
27
|
@sale_categories[cat] = [] if @sale_categories[cat].nil?
|
28
28
|
@sale_categories[cat] << p
|
29
29
|
end
|
30
|
+
add_ga_event('products', 'view', 'Sales')
|
30
31
|
render 'caboose/products/sales' and return
|
31
32
|
|
32
33
|
elsif params[:id].to_i > 0 && Product.exists?(params[:id])
|
@@ -38,6 +39,7 @@ module Caboose
|
|
38
39
|
@reviews = Review.where(:product_id => @product.id).limit(10).order("id DESC") || nil
|
39
40
|
@logged_in_user = logged_in_user
|
40
41
|
|
42
|
+
add_ga_event('products', 'view', "Product #{@product.id}")
|
41
43
|
render 'caboose/products/details' and return
|
42
44
|
end
|
43
45
|
end
|
@@ -116,10 +118,11 @@ module Caboose
|
|
116
118
|
@products = @pager.items
|
117
119
|
@category = if @filter['category_id'] then Category.find(@filter['category_id'].to_i) else nil end
|
118
120
|
|
119
|
-
@pager.set_item_count
|
121
|
+
@pager.set_item_count
|
122
|
+
add_ga_event('products', 'view', "Category #{cat.id}")
|
120
123
|
end
|
121
124
|
|
122
|
-
def show
|
125
|
+
def show
|
123
126
|
end
|
124
127
|
|
125
128
|
# GET /product/info
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Caboose
|
4
|
+
class GA # Google Analytics
|
5
|
+
|
6
|
+
def self.event(site_id, category, action, label = nil, value = nil)
|
7
|
+
|
8
|
+
site = Site.where(:id => site_id).first
|
9
|
+
return if site.nil?
|
10
|
+
sc = site.social_config
|
11
|
+
ga_id = sc.google_analytics_id
|
12
|
+
return if ga_id.nil? || ga_id.strip.length == 0
|
13
|
+
|
14
|
+
params = {
|
15
|
+
'v' => 1,
|
16
|
+
'tid' => ga_id,
|
17
|
+
'cid' => site.id,
|
18
|
+
't' => "event",
|
19
|
+
'ec' => category,
|
20
|
+
'ea' => action
|
21
|
+
}
|
22
|
+
params['el'] = label if label
|
23
|
+
params['ev'] = value if value
|
24
|
+
|
25
|
+
HTTParty.get('https://www.google-analytics.com', { 'query' => params })
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -652,7 +652,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
652
652
|
[ :rss_url , :string ],
|
653
653
|
[ :google_plus_url , :string ],
|
654
654
|
[ :linkedin_url , :string ],
|
655
|
-
[ :google_analytics_id , :string ]
|
655
|
+
[ :google_analytics_id , :string ],
|
656
|
+
[ :auto_ga_js , :boolean , { :default => false }]
|
656
657
|
],
|
657
658
|
Caboose::StackableGroup => [
|
658
659
|
[ :name , :string ],
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%
|
2
|
+
sc = site.social_config
|
3
|
+
if sc.auto_ga_js && sc.google_analytics_id
|
4
|
+
%>
|
5
|
+
<script>
|
6
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
7
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
8
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
9
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
10
|
+
ga('create', '<%= raw sc.google_analytics_id %>', 'auto');
|
11
|
+
ga('send', 'pageview');
|
12
|
+
<% if ga_events && ga_events.count > 0 %>
|
13
|
+
<% ga_events.each do |arr| %>
|
14
|
+
<%
|
15
|
+
cat = arr[0] ? arr[0] : nil
|
16
|
+
action = arr[1] ? arr[1] : nil
|
17
|
+
label = arr[2] ? arr[2] : nil
|
18
|
+
value = arr[3] ? arr[3] : nil
|
19
|
+
arr2 = [cat, action]
|
20
|
+
arr2 << (label ? label : '') if label || (label.nil? && value)
|
21
|
+
arr2 << value if value
|
22
|
+
%>
|
23
|
+
ga('send', 'event'<% arr2.each do |x| %>, <%= raw Caboose.json(x) %><% end %>);
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
26
|
+
</script>
|
27
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% if ga_events && ga_events.count > 0 %>
|
2
|
+
<script type='text/javascript'>
|
3
|
+
<% ga_events.each do |arr| %>
|
4
|
+
<%
|
5
|
+
cat = arr[0] ? arr[0] : nil
|
6
|
+
action = arr[1] ? arr[1] : nil
|
7
|
+
label = arr[2] ? arr[2] : nil
|
8
|
+
value = arr[3] ? arr[3] : nil
|
9
|
+
arr2 = [cat, action]
|
10
|
+
arr2 << (label ? label : '') if label || (label.nil? && value)
|
11
|
+
arr2 << value if value
|
12
|
+
%>
|
13
|
+
ga('send', 'event', <% arr2.each do |x| %>, <%= raw Caboose.json(x) %><% end %>);
|
14
|
+
<% end %>
|
15
|
+
</script>
|
16
|
+
<% end %>
|
@@ -14,6 +14,7 @@ sc = @social_config
|
|
14
14
|
<p><div id="socialconfig_<%= sc.id %>_google_plus_url" ></div></p>
|
15
15
|
<p><div id="socialconfig_<%= sc.id %>_linkedin_url" ></div></p>
|
16
16
|
<p><div id="socialconfig_<%= sc.id %>_google_analytics_id" ></div></p>
|
17
|
+
<p><div id="socialconfig_<%= sc.id %>_auto_ga_js" ></div></p>
|
17
18
|
|
18
19
|
<div id='message'></div>
|
19
20
|
|
@@ -29,16 +30,17 @@ $(document).ready(function() {
|
|
29
30
|
update_url: '/admin/social',
|
30
31
|
authenticity_token: '<%= form_authenticity_token %>',
|
31
32
|
attributes: [
|
32
|
-
{ name: 'facebook_page_id'
|
33
|
-
{ name: 'twitter_username'
|
34
|
-
{ name: 'instagram_username'
|
35
|
-
{ name: 'youtube_url'
|
36
|
-
{ name: 'pinterest_url'
|
37
|
-
{ name: 'vimeo_url'
|
38
|
-
{ name: 'rss_url'
|
39
|
-
{ name: 'google_plus_url'
|
40
|
-
{ name: 'linkedin_url'
|
41
|
-
{ name: 'google_analytics_id' , nice_name: 'Google Analytics Tracking ID'
|
33
|
+
{ name: 'facebook_page_id' , nice_name: 'Facebook Page ID' , type: 'text' , value: <%= raw Caboose.json(sc.facebook_page_id) %>, width: 500 },
|
34
|
+
{ name: 'twitter_username' , nice_name: 'Twitter Username' , type: 'text' , value: <%= raw Caboose.json(sc.twitter_username) %>, width: 500 },
|
35
|
+
{ name: 'instagram_username' , nice_name: 'Instagram Username' , type: 'text' , value: <%= raw Caboose.json(sc.instagram_username) %>, width: 500 },
|
36
|
+
{ name: 'youtube_url' , nice_name: 'YouTube Channel ID' , type: 'text' , value: <%= raw Caboose.json(sc.youtube_url) %>, width: 500 },
|
37
|
+
{ name: 'pinterest_url' , nice_name: 'Pinterest URL' , type: 'text' , value: <%= raw Caboose.json(sc.pinterest_url) %>, width: 500 },
|
38
|
+
{ name: 'vimeo_url' , nice_name: 'Vimeo URL' , type: 'text' , value: <%= raw Caboose.json(sc.vimeo_url) %>, width: 500 },
|
39
|
+
{ name: 'rss_url' , nice_name: 'RSS Feed URL' , type: 'text' , value: <%= raw Caboose.json(sc.rss_url) %>, width: 500 },
|
40
|
+
{ name: 'google_plus_url' , nice_name: 'Google Plus URL' , type: 'text' , value: <%= raw Caboose.json(sc.google_plus_url) %>, width: 500 },
|
41
|
+
{ name: 'linkedin_url' , nice_name: 'LinkedIn URL' , type: 'text' , value: <%= raw Caboose.json(sc.linkedin_url) %>, width: 500 },
|
42
|
+
{ name: 'google_analytics_id' , nice_name: 'Google Analytics Tracking ID' , type: 'text' , value: <%= raw Caboose.json(sc.google_analytics_id) %>, width: 500 },
|
43
|
+
{ name: 'auto_ga_js' , nice_name: 'Auto Embed Google Analytics JS' , type: 'checkbox' , value: <%= sc.auto_ga_js ? 1 : 0 %>, width: 500 }
|
42
44
|
]
|
43
45
|
});
|
44
46
|
|
@@ -48,9 +48,10 @@
|
|
48
48
|
:csrf_meta_tags => '|CABOOSE_CSRF|',
|
49
49
|
:csrf_meta_tags2 => '|CABOOSE_CSRF|',
|
50
50
|
:logged_in_user => @logged_in_user,
|
51
|
-
:site => @site
|
51
|
+
:site => @site,
|
52
|
+
:ga_events => @ga_events
|
52
53
|
}
|
53
|
-
@block_options.each{ |k,v| options[k] = v } if @block_options
|
54
|
+
@block_options.each{ |k,v| options[k] = v } if @block_options
|
54
55
|
|
55
56
|
str = nil
|
56
57
|
#if @use_page_cache
|
@@ -88,6 +89,8 @@
|
|
88
89
|
if @site.use_retargeting
|
89
90
|
js << b.partial('retargeting', options)
|
90
91
|
end
|
92
|
+
|
93
|
+
js << b.partial('ga', options)
|
91
94
|
|
92
95
|
str.gsub!('|CABOOSE_CSS|' , css)
|
93
96
|
str.gsub!('|CABOOSE_PROTOCOL|' , protocol)
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.220
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
@@ -615,6 +615,7 @@ files:
|
|
615
615
|
- app/models/caboose/discount.rb
|
616
616
|
- app/models/caboose/domain.rb
|
617
617
|
- app/models/caboose/font.rb
|
618
|
+
- app/models/caboose/ga.rb
|
618
619
|
- app/models/caboose/gift_card.rb
|
619
620
|
- app/models/caboose/line_item.rb
|
620
621
|
- app/models/caboose/line_item_modification.rb
|
@@ -700,6 +701,8 @@ files:
|
|
700
701
|
- app/views/caboose/blocks/_checkbox.html.erb
|
701
702
|
- app/views/caboose/blocks/_controller_view_content.html.erb
|
702
703
|
- app/views/caboose/blocks/_file.html.erb
|
704
|
+
- app/views/caboose/blocks/_ga.html.erb
|
705
|
+
- app/views/caboose/blocks/_ga_events.html.erb
|
703
706
|
- app/views/caboose/blocks/_google_spreadsheet_cell_value.html.erb
|
704
707
|
- app/views/caboose/blocks/_heading.html.erb
|
705
708
|
- app/views/caboose/blocks/_html.html.erb
|