workarea-google_analytics 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +15 -0
  7. data/.rspec +2 -0
  8. data/.yardopts +1 -0
  9. data/CHANGELOG.md +217 -0
  10. data/CODE_OF_CONDUCT.md +3 -0
  11. data/CONTRIBUTING.md +3 -0
  12. data/Gemfile +6 -0
  13. data/LICENSE +52 -0
  14. data/README.md +589 -0
  15. data/Rakefile +31 -0
  16. data/app/assets/javascripts/workarea/storefront/google_analytics/modules/adapter.js +314 -0
  17. data/app/views/workarea/storefront/analytics/_google_analytics.html.haml +6 -0
  18. data/bin/rails +18 -0
  19. data/config/initializers/appends.rb +9 -0
  20. data/config/initializers/configuration.rb +1 -0
  21. data/config/routes.rb +2 -0
  22. data/lib/tasks/google_analytics_tasks.rake +4 -0
  23. data/lib/workarea/google_analytics/engine.rb +8 -0
  24. data/lib/workarea/google_analytics/version.rb +5 -0
  25. data/lib/workarea/google_analytics.rb +10 -0
  26. data/test/dummy/README.rdoc +28 -0
  27. data/test/dummy/Rakefile +6 -0
  28. data/test/dummy/app/assets/images/.keep +0 -0
  29. data/test/dummy/app/assets/javascripts/application.js +13 -0
  30. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  31. data/test/dummy/app/controllers/application_controller.rb +5 -0
  32. data/test/dummy/app/controllers/concerns/.keep +0 -0
  33. data/test/dummy/app/helpers/application_helper.rb +2 -0
  34. data/test/dummy/app/mailers/.keep +0 -0
  35. data/test/dummy/app/models/.keep +0 -0
  36. data/test/dummy/app/models/concerns/.keep +0 -0
  37. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  38. data/test/dummy/bin/bundle +3 -0
  39. data/test/dummy/bin/rails +4 -0
  40. data/test/dummy/bin/rake +4 -0
  41. data/test/dummy/bin/setup +34 -0
  42. data/test/dummy/bin/update +29 -0
  43. data/test/dummy/config/application.rb +21 -0
  44. data/test/dummy/config/boot.rb +5 -0
  45. data/test/dummy/config/cable.yml +9 -0
  46. data/test/dummy/config/environment.rb +5 -0
  47. data/test/dummy/config/environments/development.rb +57 -0
  48. data/test/dummy/config/environments/production.rb +86 -0
  49. data/test/dummy/config/environments/test.rb +43 -0
  50. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  51. data/test/dummy/config/initializers/assets.rb +11 -0
  52. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  53. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  54. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  55. data/test/dummy/config/initializers/inflections.rb +16 -0
  56. data/test/dummy/config/initializers/mime_types.rb +4 -0
  57. data/test/dummy/config/initializers/new_framework_defaults.rb +17 -0
  58. data/test/dummy/config/initializers/session_store.rb +3 -0
  59. data/test/dummy/config/initializers/workarea.rb +7 -0
  60. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  61. data/test/dummy/config/locales/en.yml +23 -0
  62. data/test/dummy/config/puma.rb +47 -0
  63. data/test/dummy/config/routes.rb +5 -0
  64. data/test/dummy/config/secrets.yml +22 -0
  65. data/test/dummy/config/spring.rb +6 -0
  66. data/test/dummy/config.ru +4 -0
  67. data/test/dummy/db/seeds.rb +10 -0
  68. data/test/dummy/lib/assets/.keep +0 -0
  69. data/test/dummy/log/.keep +0 -0
  70. data/test/dummy/public/404.html +67 -0
  71. data/test/dummy/public/422.html +67 -0
  72. data/test/dummy/public/500.html +66 -0
  73. data/test/dummy/public/favicon.ico +1 -0
  74. data/test/test_helper.rb +10 -0
  75. data/workarea-google_analytics.gemspec +21 -0
  76. metadata +132 -0
data/README.md ADDED
@@ -0,0 +1,589 @@
1
+ WebLinc Google Analytics
2
+ ================================================================================
3
+
4
+ A Workarea Commerce plugin for Google Analytics.
5
+
6
+ This plugin adds the Google Analytics (GA) script to the head of the site.
7
+ It also adds an analytics adapter and registers several callbacks for Workarea events which send a payload of data to GA.
8
+ This includes advanced ecommerce events, as well as custom events.
9
+
10
+ All OOTB events are listed below, payloads contain sample data.
11
+
12
+ Getting Started
13
+ --------------------------------------------------------------------------------
14
+
15
+ Add the gem to your application's Gemfile:
16
+
17
+ ```ruby
18
+ # ...
19
+ gem 'workarea-google_analytics'
20
+ # ...
21
+ ```
22
+
23
+ Update your application's bundle.
24
+
25
+ ```bash
26
+ cd path/to/application
27
+ bundle
28
+ ```
29
+
30
+ Configuration
31
+ --------------------------------------------------------------------------------
32
+
33
+ To integrate your Workarea application with Google Analytics you need configure your host application with your Google Analytics tracking ID.
34
+
35
+ You should use application secrets to do this. Add the following to your `config/secrets.yml` file
36
+
37
+ ```yaml
38
+ google_analytics:
39
+ :tracking_id: UA-2499240-11
40
+ ```
41
+
42
+ Then in workarea.rb add the following config:
43
+
44
+ ```ruby
45
+ Workarea.configure do |config|
46
+ config.google_analytics_tracking_id = Rails.application.secrets.google_analytics[:tracking_id]
47
+ end
48
+ ```
49
+
50
+ Shared Payloads
51
+ --------------------------------------------------------------------------------
52
+
53
+ These payloads are shared by many of the events detailed in the Summary of events below
54
+
55
+ #### Product Analytics data
56
+
57
+ Payload:
58
+
59
+ id: "4559F84840",
60
+ name: "Slim Ankle Pants",
61
+ sku: "292205283-4",
62
+ sale: false,
63
+ price: 31.56,
64
+ category: "Women's Pants"
65
+
66
+ ---
67
+
68
+ #### Order Analytics Data
69
+
70
+ Payload:
71
+
72
+ site_name: 'Site Name',
73
+ id: 'CF6D17E28B',
74
+ promo_codes: ['10percentoff'],
75
+ shipping_service: 'USPS',
76
+ shipping_total: 7.00,
77
+ tax_total: 6.39,
78
+ total_price: 84.23,
79
+ tenders: 'Visa',
80
+ items: Order Item Analytics Data (below) for each item in order.
81
+
82
+ ---
83
+
84
+ #### Order Item Analytics Data
85
+
86
+ Payload:
87
+
88
+ id: "4559F84840",
89
+ product_id: "4559F84840",
90
+ product_name: "Slim Ankle Pants",
91
+ sku: "292205283-4",
92
+ price: 31.56,
93
+ quantity: 1,
94
+ category: "Women's Pants"
95
+
96
+
97
+ Summary of Events
98
+ --------------------------------------------------------------------------------
99
+ #### Page View
100
+ - Sent on every page, along with other events.
101
+ - No payload.
102
+ - No Events
103
+
104
+ ---
105
+
106
+ #### Category View
107
+
108
+ Sent on category show pages (aka product browse)
109
+
110
+ Payload:
111
+
112
+ name: "Women's Pants",
113
+ sort: "top_sellers",
114
+ page: 1,
115
+ filters: {
116
+ color: ['Red', 'Blue'],
117
+ size: ['Small'],
118
+ price: ['30.0-39.99']
119
+ }
120
+
121
+ Sends 4 events:
122
+
123
+ | category | action | label | value |
124
+ |----------|--------|-------|-------|
125
+ | 'category' | 'view' | "Women's Pants" | |
126
+ | 'category' | 'view' | "top_sellers" | |
127
+ | 'category' | 'view' | 'page: 1' | |
128
+ | 'category' | 'view' | 'color: Red, Blue' | |
129
+ | 'category' | 'view' | 'size: Small' | |
130
+ | 'category' | 'view' | 'price: 30.0-39.99' | |
131
+
132
+ ---
133
+
134
+ #### Search Results View
135
+ Sent on search results page
136
+
137
+ Payload:
138
+
139
+ terms: 'red shirt',
140
+ sort: 'relevance',
141
+ page: 1,
142
+ filters: {
143
+ size: ['Small'],
144
+ price: ['30.0-39.99']
145
+ },
146
+ totalResults: 4
147
+
148
+ Sends 4 events:
149
+
150
+ | category | action | label | value |
151
+ |----------|--------|-------|-------|
152
+ | 'search results' | 'view' | 'red shirt' | |
153
+ | 'search results' | 'view' | 'relevance' | |
154
+ | 'search results' | 'view' | 'page: 1' | |
155
+ | 'search results' | 'view' | 'size : small' | |
156
+ | 'search results' | 'view' | 'price : 30.0-39.99' | |
157
+
158
+ ---
159
+
160
+ #### Product List
161
+ Sent anywhere there are lists of products, including: product browse, search results, cart page, product recommendations, category summary content block, product list content block.
162
+
163
+ Payload:
164
+
165
+ name: 'Search results for "Red Shirt"', (name of the list e.g. 'Cart' or 'Custom product list')
166
+ page: 1,
167
+ per_page: 20,
168
+ impressions: Product Analytics Data
169
+
170
+ Sends enhanced ecommerce event 'ec:addImpression' with the following options:
171
+
172
+ 'id': "4559F84840",
173
+ 'name': "Slim Ankle Pants",
174
+ 'category': "Women's Pants",
175
+ 'variant': "292205283-4",
176
+ 'position': 1
177
+
178
+ ---
179
+
180
+ #### Product Click
181
+ Triggered when a user clicks on any product summary in the storefront.
182
+
183
+ Payload: Product Analytics Data
184
+
185
+ Sends 3 events
186
+ 'ec:addProduct' with the following options:
187
+
188
+ 'id':"4559F84840",
189
+ 'name': "Slim Ankle Pants",
190
+ 'category': "Women's Pants",
191
+ 'variant': "292205283-4",
192
+ 'position': 1
193
+
194
+ 'ec:setAction' click
195
+
196
+ list: payload.list (the product list name)
197
+
198
+ | category | action | label | value |
199
+ |----------|--------|-------|-------|
200
+ | 'product' | 'click' | "Women's Pants" | |
201
+
202
+ ---
203
+
204
+ ### Product Quickview
205
+ Triggered when a user opens a product quickview
206
+
207
+ Payload: Product Analytics Data
208
+
209
+ Sends 3 events
210
+
211
+ 'ec:addProduct' with the following options:
212
+
213
+ 'id':"4559F84840",
214
+ 'name': "Slim Ankle Pants",
215
+ 'category': "Women's Pants",
216
+ 'variant': "292205283-4",
217
+
218
+ 'ec:setAction' detail
219
+
220
+ | category | action | label | value |
221
+ |----------|--------|-------|-------|
222
+ | 'product' | 'quickview' | | |
223
+
224
+ ---
225
+
226
+ ### Product View
227
+ Triggered when a user visits the product detail page
228
+
229
+ Payload - Product Analytics Data
230
+
231
+ Sends 2 events
232
+
233
+ 'ec:addProduct' with the following options:
234
+
235
+ 'id':"4559F84840",
236
+ 'name': "Slim Ankle Pants",
237
+ 'category': "Women's Pants",
238
+ 'variant': "292205283-4",
239
+ 'nonInteraction': true
240
+
241
+ 'ec:setAction' detail
242
+
243
+ ---
244
+
245
+ ### Add to cart
246
+ Triggered when add to cart button is clicked
247
+
248
+ Payload: Product Analytics Data
249
+
250
+ Sends 3 events
251
+
252
+ 'ec:addProduct' with the following options:
253
+
254
+ 'id':"4559F84840",
255
+ 'name': "Slim Ankle Pants",
256
+ 'category': "Women's Pants",
257
+ 'variant': "292205283-4",
258
+ 'price': 31.56,
259
+ 'quantity': 1
260
+
261
+ 'ec:setAction' add
262
+
263
+ | category | action | label | value |
264
+ |----------|--------|-------|-------|
265
+ | 'product' | 'click' | 'add to cart' | |
266
+
267
+ ---
268
+
269
+ ### Cart View
270
+ Triggered when the cart page is opened, including cart summaries (drawer or dropdown)
271
+
272
+ Payload: Order Analytics Data
273
+
274
+ Sends 2 events
275
+
276
+ 'ec:addProduct' for each product in cart with the following options:
277
+
278
+ 'id': "5AE9E86D6C",
279
+ 'name': "Slim Ankle Pants",
280
+ 'category': "Women's Pants",
281
+ 'variant': "292205283-4",
282
+ 'price': 31.56,
283
+ 'quantity': 1
284
+ 'nonInteraction': true
285
+
286
+ 'ec:setAction' 'checkout' { 'step' : 1 }
287
+
288
+ ---
289
+
290
+ ### Update Cart Item
291
+ Triggered when a cart item is updated (quantity changed)
292
+
293
+ Payload: Order Item Analytics Data
294
+
295
+ | category | action | label | value |
296
+ |----------|--------|-------|-------|
297
+ | 'product' | 'click' | 'update cart' | |
298
+
299
+ ---
300
+
301
+ ### Add To Cart Confirmation
302
+ Triggered when a cart item is added to the cart (confirmation dialog)
303
+
304
+ Payload: Order Item Analytics Data
305
+
306
+ | category | action | label | value |
307
+ |----------|--------|-------|-------|
308
+ | 'Add To Cart' | 'confirm' | 'item added' | |
309
+
310
+ ---
311
+
312
+ ### Remove from Cart
313
+ Triggered when a product is removed from the cart
314
+
315
+ Payload: Order Item Analytics Data
316
+
317
+ Sends 3 events
318
+
319
+ 'ec:addProduct' with the following options:
320
+
321
+ 'id': "5AE9E86D6C",
322
+ 'name': "Slim Ankle Pants",
323
+ 'category': "Women's Pants",
324
+ 'variant': "292205283-4",
325
+ 'price': 31.56,
326
+ 'quantity': 1
327
+
328
+ 'ec:setAction' remove
329
+
330
+ | category | action | label | value |
331
+ |----------|--------|-------|-------|
332
+ | 'product' | 'click' | 'remove from cart' | |
333
+
334
+ ---
335
+
336
+ ### Checkout Login
337
+ Triggered when user logs in during checkout
338
+
339
+ Payload: none
340
+
341
+ | category | action | label | value |
342
+ |----------|--------|-------|-------|
343
+ | 'checkout' | 'start' | 'login' | |
344
+
345
+ ---
346
+
347
+ ### Checkout Guest
348
+ Triggered when user begins checkout as a guest (no login)
349
+
350
+ Payload: none
351
+
352
+ | category | action | label | value |
353
+ |----------|--------|-------|-------|
354
+ | 'checkout' | 'start' | 'guest' | |
355
+
356
+ ---
357
+
358
+ ### Checkout Addresses View
359
+ Triggered on the Addresses step of checkout
360
+
361
+ Payload: Order Analytics Data
362
+
363
+ 'ec:addProduct' for each product in cart with the following options:
364
+
365
+ 'id': "5AE9E86D6C",
366
+ 'name': "Slim Ankle Pants",
367
+ 'category': "Women's Pants",
368
+ 'variant': "292205283-4",
369
+ 'price': 31.56,
370
+ 'quantity': 1
371
+ 'nonInteraction': true
372
+
373
+ 'ec:setAction' 'checkout' { 'step' : 2 }
374
+
375
+ ---
376
+
377
+ ### Checkout Shipping View
378
+ Triggered on the Shipping step of checkout
379
+
380
+ 'ec:addProduct' for each product in cart with the following options:
381
+
382
+ 'id': "5AE9E86D6C",
383
+ 'name': "Slim Ankle Pants",
384
+ 'category': "Women's Pants",
385
+ 'variant': "292205283-4",
386
+ 'price': 31.56,
387
+ 'quantity': 1
388
+ 'nonInteraction': true
389
+
390
+ 'ec:setAction' 'checkout' { 'step' : 3 }
391
+
392
+ ---
393
+
394
+ ### Checkout Payment View
395
+ Triggered on the Payment step of checkout
396
+
397
+ 'ec:addProduct' for each product in cart with the following options:
398
+
399
+ 'id': "5AE9E86D6C",
400
+ 'name': "Slim Ankle Pants",
401
+ 'category': "Women's Pants",
402
+ 'variant': "292205283-4",
403
+ 'price': 31.56,
404
+ 'quantity': 1
405
+ 'nonInteraction': true
406
+
407
+ 'ec:setAction' 'checkout' { 'step' : 4 }
408
+
409
+ ---
410
+
411
+ ### Checkout Payment Selected
412
+ Triggered when a payment option is clicked on the payment step of checkout.
413
+
414
+ Payload:
415
+
416
+ type: 'new card'
417
+
418
+ 'ec:setAction' 'checkout_option' { step: 4, option: payload.name }
419
+
420
+ ---
421
+
422
+ ### Checkout order placed
423
+ Triggered on the order confirmation page of checkout
424
+
425
+ Payload: Order Analytics Data
426
+
427
+ 'ec:addProduct' for each product in cart with the following options:
428
+
429
+ 'id': "5AE9E86D6C",
430
+ 'name': "Slim Ankle Pants",
431
+ 'category': "Women's Pants",
432
+ 'variant': "292205283-4",
433
+ 'price': 31.56,
434
+ 'quantity': 1
435
+ 'nonInteraction': true
436
+
437
+ 'ec:purchase' with the following options:
438
+
439
+ 'id': 'CF6D17E28B',
440
+ 'affiliation': 'Site Name',
441
+ 'revenue': 84.23,
442
+ 'tax': 6.39,
443
+ 'shipping': 7.00,
444
+ 'coupon': ['10percentoff']
445
+
446
+ ---
447
+
448
+ ### Checkout Signup
449
+ Triggered when user signs up for email notification in checkout
450
+
451
+ Payload: none
452
+
453
+ | category | action | label | value |
454
+ |----------|--------|-------|-------|
455
+ | 'checkout' | 'signup' | | |
456
+
457
+ ---
458
+
459
+ ### Login
460
+ Triggered when user logs in to their account (not in checkout)
461
+
462
+ Payload: none
463
+
464
+ | category | action | label | value |
465
+ |----------|--------|-------|-------|
466
+ | 'account' | 'login' | | |
467
+
468
+ ---
469
+
470
+ ### Logout
471
+ Triggered when user logs in to their account (not in checkout)
472
+
473
+ Payload: none
474
+
475
+ | category | action | label | value |
476
+ |----------|--------|-------|-------|
477
+ | 'account' | 'logout' | | |
478
+
479
+ ---
480
+
481
+ ### Forgot Password
482
+ Triggered when user submits the forgot password form
483
+
484
+ Payload: none
485
+
486
+ | category | action | label | value |
487
+ |----------|--------|-------|-------|
488
+ | 'account' | 'forgot password' | | |
489
+
490
+ ---
491
+
492
+ ### Signup
493
+ Triggered when user creates a new account (not in checkout)
494
+
495
+ Payload: none
496
+
497
+ | category | action | label | value |
498
+ |----------|--------|-------|-------|
499
+ | 'account' | 'signup' | | |
500
+
501
+ ---
502
+
503
+ ### Share
504
+ Triggered when user clicks on one of the share buttons
505
+
506
+ Payload:
507
+
508
+ type: share_type e.g. 'facebook'
509
+
510
+ | category | action | label | value |
511
+ |----------|--------|-------|-------|
512
+ | 'share' | 'click' | 'facebook' | |
513
+
514
+ ---
515
+
516
+ ### Email Signup
517
+ Triggered when user signs up for email notifications (not in checkout)
518
+
519
+ Payload: none
520
+
521
+ | category | action | label | value |
522
+ |----------|--------|-------|-------|
523
+ | 'email' | 'signup' | | |
524
+
525
+ ---
526
+
527
+ ### Primary Navigation Click
528
+ Triggered when user clicks on a link in the primary navigation
529
+
530
+ Payload:
531
+
532
+ name: 'Sale'
533
+ url: 'www.yoursite.com/sale'
534
+
535
+ | category | action | label | value |
536
+ |----------|--------|-------|-------|
537
+ | 'nav' | 'select' | 'Sale' | |
538
+
539
+ ---
540
+
541
+ ### Checkout Edit
542
+ Triggered when user clicks on an 'edit' button in checkout to change address or shipping.
543
+
544
+ Payload:
545
+
546
+ type: step to edit ('addresses', 'shipping')
547
+
548
+ | category | action | label | value |
549
+ |----------|--------|-------|-------|
550
+ | 'Edit Button' | 'click' | 'addresses' | |
551
+
552
+ ---
553
+
554
+ ### Flash Message
555
+ Triggered when a system flash message is shown
556
+
557
+ Payload:
558
+
559
+ type: type (success | error | info)
560
+
561
+ | category | action | label | value |
562
+ |----------|--------|-------|-------|
563
+ | 'Flash Messaging' | 'Flash Messaging Triggered' | 'success' | |
564
+
565
+ ---
566
+
567
+ ### Validation Error
568
+ Triggered when a jQuery validation message is displayed
569
+
570
+ Payload:
571
+
572
+ location: checkout_page
573
+
574
+ Note: if this event happens outside fo checkout the location is set to 'application'
575
+
576
+ | category | action | label | value |
577
+ |----------|--------|-------|-------|
578
+ | 'JavaScript Validaton Error' | 'JavaScript Validation Error Triggered' | 'checkout - payment' | |
579
+
580
+
581
+ Workarea Commerce Documentation
582
+ --------------------------------------------------------------------------------
583
+
584
+ See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation.
585
+
586
+ License
587
+ --------------------------------------------------------------------------------
588
+
589
+ Workarea Google Analytics is released under the [Business Software License](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
8
+ load 'rails/tasks/engine.rake'
9
+ load 'rails/tasks/statistics.rake'
10
+ load 'workarea/changelog.rake'
11
+
12
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
13
+ require 'workarea/google_analytics/version'
14
+
15
+ desc "Release version #{Workarea::GoogleAnalytics::VERSION} of the gem"
16
+ task :release do
17
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
18
+
19
+ #Rake::Task['workarea:changelog'].execute
20
+ #system 'git add CHANGELOG.md'
21
+ #system 'git commit -m "Update CHANGELOG"'
22
+ #system 'git push origin HEAD'
23
+
24
+ system "git tag -a v#{Workarea::GoogleAnalytics::VERSION} -m 'Tagging #{Workarea::GoogleAnalytics::VERSION}'"
25
+ system 'git push --tags'
26
+
27
+ system 'gem build workarea-google_analytics.gemspec'
28
+ system "gem push workarea-google_analytics-#{Workarea::GoogleAnalytics::VERSION}.gem"
29
+ system "gem push workarea-google_analytics-#{Workarea::GoogleAnalytics::VERSION}.gem --host #{host}"
30
+ system "rm workarea-google_analytics-#{Workarea::GoogleAnalytics::VERSION}.gem"
31
+ end