ga_events 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -1
- data/README.md +46 -4
- data/Rakefile +5 -0
- data/app/assets/javascripts/ga_events.js.coffee +36 -10
- data/ga_events.gemspec +2 -0
- data/lib/ga_events/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2da2467a5f1cf24ef9fdcd30dfea8130a6e5a1c2a8ce6e0903143a909215e30d
|
4
|
+
data.tar.gz: b617a6d911b6666a8b1f0dabae680950565f956adccf26850a443a3109602c23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 805237d9af985bd8c4cb9d696626f4949d953dcabb3669b1b80771209811f13402f27e25aa618eda39bce2cfdf767ae9f74fa8336f789e5a5ee79a82e59e8026
|
7
|
+
data.tar.gz: 428a307570718be7d541f3c8883cc73141e88e7861e87a98ed5a4263ef8f41f657028220203298ea4ab5053fdbe9e1e85dc9fec59e26b50223ba5a94a0855a0a
|
data/CHANGELOG.md
CHANGED
@@ -40,7 +40,7 @@ The format suggested at http://keepachangelog.com/ is used.
|
|
40
40
|
- Ensure category, action and label do not include any umlauts or ß chars
|
41
41
|
- Fixed an error where events are remaining after a redirect
|
42
42
|
|
43
|
-
## 2.0.0 -
|
43
|
+
## 2.0.0 - 2020-11-20
|
44
44
|
|
45
45
|
### Removed
|
46
46
|
- Support for rubies < 2.3
|
@@ -48,3 +48,19 @@ The format suggested at http://keepachangelog.com/ is used.
|
|
48
48
|
|
49
49
|
### Added
|
50
50
|
- Compatibility for Rails 5
|
51
|
+
|
52
|
+
## 2.1.0 - 2021-09-07
|
53
|
+
|
54
|
+
### Added
|
55
|
+
- Optional user consent flag to prevent event flushing until consent was given
|
56
|
+
|
57
|
+
## 3.0.0 - 2022-01-10
|
58
|
+
|
59
|
+
### Added
|
60
|
+
- Universal Analytics Adapter can be configured to use `gtag.js` instead of
|
61
|
+
`analytics.js` event syntax
|
62
|
+
- [Breaking] The constructor interface has changed due to more configuration
|
63
|
+
options that differ between `analytics.js` and `gtag.js`.
|
64
|
+
- Universal Analytics Adapter can be configured to use a custom name for the
|
65
|
+
analytics object (defaults to `window.ga()` for `analytics.js` and
|
66
|
+
`window.gtag()` for `gtag.js`)
|
data/README.md
CHANGED
@@ -43,7 +43,9 @@ GaEvents.Event.adapter = function() {
|
|
43
43
|
}
|
44
44
|
```
|
45
45
|
|
46
|
-
### Google Universal Analytics
|
46
|
+
### Google Universal Analytics
|
47
|
+
|
48
|
+
#### analytics.js
|
47
49
|
|
48
50
|
```javascript
|
49
51
|
GaEvents.Event.adapter = function() {
|
@@ -51,11 +53,49 @@ GaEvents.Event.adapter = function() {
|
|
51
53
|
}
|
52
54
|
```
|
53
55
|
|
54
|
-
Optionally you can specify a custom method to call and a custom tracker
|
56
|
+
Optionally you can specify a custom send method to call and a custom tracker
|
57
|
+
name:
|
58
|
+
|
59
|
+
```javascript
|
60
|
+
GaEvents.Event.adapter = function() {
|
61
|
+
return new GaEvents.GoogleUniversalAnalyticsAdapter(
|
62
|
+
{send_method_name: "sendNow", tracker_name: "customTracker"}
|
63
|
+
);
|
64
|
+
}
|
65
|
+
```
|
66
|
+
|
67
|
+
#### gtag.js
|
68
|
+
|
69
|
+
```javascript
|
70
|
+
GaEvents.Event.adapter = function() {
|
71
|
+
return new GaEvents.GoogleUniversalAnalyticsAdapter(
|
72
|
+
{use_gtag_variant: true}
|
73
|
+
);
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
Optionally you can specify a custom tracker GA_MEASUREMENT_ID where you want
|
78
|
+
your events to be sent to:
|
79
|
+
|
80
|
+
```javascript
|
81
|
+
GaEvents.Event.adapter = function() {
|
82
|
+
return new GaEvents.GoogleUniversalAnalyticsAdapter(
|
83
|
+
{use_gtag_variant: true, tracker_name: "GA_MEASUREMENT_ID"}
|
84
|
+
);
|
85
|
+
}
|
86
|
+
```
|
87
|
+
|
88
|
+
#### Optional custom object name
|
89
|
+
|
90
|
+
The default names of the analytics object are `window.ga()` for `analytics.js`
|
91
|
+
and `window.gtag()` for `gtag.js`. If you have renamed your analytics object,
|
92
|
+
you can specify the name:
|
55
93
|
|
56
94
|
```javascript
|
57
95
|
GaEvents.Event.adapter = function() {
|
58
|
-
return new GaEvents.GoogleUniversalAnalyticsAdapter(
|
96
|
+
return new GaEvents.GoogleUniversalAnalyticsAdapter(
|
97
|
+
{analytics_object_name: "analytics"} // calls window.analytics()
|
98
|
+
);
|
59
99
|
}
|
60
100
|
```
|
61
101
|
|
@@ -161,5 +201,7 @@ Yes please! Use pull requests.
|
|
161
201
|
## More docs and tools
|
162
202
|
|
163
203
|
* [Google Analytics: Event Tracking](https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide)
|
204
|
+
* [Google Universal Analytics: Event Tracking (analytics.js)](https://developers.google.com/analytics/devguides/collection/analyticsjs/events)
|
205
|
+
* [Google Universal Analytics: Event Tracking (gtag.js)](https://developers.google.com/analytics/devguides/collection/gtagjs/events)
|
164
206
|
* [Google Tag Manager: Custom Events](http://support.google.com/tagmanager/answer/2574372#GoogleAnalytics)
|
165
|
-
* [Chrome Web Store:
|
207
|
+
* [Chrome Web Store: Tag Assistant](https://chrome.google.com/webstore/detail/tag-assistant-legacy-by-g/kejbdjndbnbjgmefkgdddjlbokphdefk)
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ class GaEvents.Event
|
|
13
13
|
@user_consent_given: false
|
14
14
|
klass: @
|
15
15
|
|
16
|
-
# Decompose
|
16
|
+
# Decompose an event-string (ruby side) into an event object.
|
17
17
|
@from_string: (string) ->
|
18
18
|
$.map string.split("$"), (part) =>
|
19
19
|
[category, action, label, value] = part.split "|"
|
@@ -23,7 +23,7 @@ class GaEvents.Event
|
|
23
23
|
dom_events = $("div[data-#{@html_key}]").data @html_key
|
24
24
|
@from_string dom_events if dom_events?
|
25
25
|
|
26
|
-
# Events should not be
|
26
|
+
# Events should not be sent to an adapter unless the DOM has finished loading.
|
27
27
|
@flush: ->
|
28
28
|
return if @require_user_consent && !@user_consent_given
|
29
29
|
|
@@ -57,7 +57,6 @@ class GaEvents.Event
|
|
57
57
|
to_positive_integer: (n) ->
|
58
58
|
if isFinite(n) and parseInt(n) >= 0 then parseInt n else 1
|
59
59
|
|
60
|
-
# https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#SettingUpEventTracking
|
61
60
|
push_to_adapter: -> @klass.adapter().push @to_hash()
|
62
61
|
|
63
62
|
jQuery =>
|
@@ -84,18 +83,45 @@ class GaEvents.GoogleTagManagerAdapter
|
|
84
83
|
window.dataLayer.push data
|
85
84
|
|
86
85
|
class GaEvents.GoogleUniversalAnalyticsAdapter
|
87
|
-
constructor: (
|
88
|
-
@
|
86
|
+
constructor: (options) ->
|
87
|
+
@use_gtag_variant = options?.use_gtag_variant || false
|
88
|
+
@analytics_object_name =
|
89
|
+
options?.analytics_object_name ||
|
90
|
+
(if @use_gtag_variant then "gtag" else "ga")
|
91
|
+
|
92
|
+
# Only relevant for analytics.js
|
93
|
+
@send_method_name = options?.send_method_name || "send"
|
89
94
|
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
# https://developers.google.com/analytics/devguides/migration/ua/analyticsjs-to-gtagjs#measure_pageviews_with_specified_trackers
|
96
|
+
@tracker_name = options?.tracker_name || false
|
97
|
+
push: (data) ->
|
98
|
+
if @use_gtag_variant
|
99
|
+
options = {
|
100
|
+
"event_category": data.category,
|
101
|
+
"event_label": data.label,
|
102
|
+
"value": data.value,
|
103
|
+
"non_interaction": true
|
104
|
+
}
|
105
|
+
options["send_to"] = @tracker_name if @tracker_name
|
106
|
+
window[@analytics_object_name]("event", data.action, options)
|
107
|
+
else
|
108
|
+
method_call_name =
|
109
|
+
if @tracker_name
|
110
|
+
"#{@tracker_name}.#{@send_method_name}"
|
111
|
+
else
|
112
|
+
@send_method_name
|
113
|
+
window[@analytics_object_name](
|
114
|
+
method_call_name, "event",
|
115
|
+
data.category, data.action, data.label, data.value,
|
116
|
+
{"nonInteraction": true}
|
117
|
+
)
|
93
118
|
|
94
119
|
class GaEvents.GoogleAnalyticsAdapter
|
120
|
+
# https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#SettingUpEventTracking
|
95
121
|
# Send events non_interactive => no influence on bounce rates
|
96
|
-
push: (
|
122
|
+
push: (data) ->
|
97
123
|
window._gaq.push(
|
98
|
-
["_trackEvent",
|
124
|
+
["_trackEvent", data.category, data.action, data.label, data.value, true]
|
99
125
|
)
|
100
126
|
|
101
127
|
class GaEvents.NullAdapter
|
data/ga_events.gemspec
CHANGED
data/lib/ga_events/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ga_events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Dütsch
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -52,7 +52,8 @@ files:
|
|
52
52
|
- spec/middleware_spec.rb
|
53
53
|
- spec/spec_helper.rb
|
54
54
|
homepage: https://github.com/Nix-wie-weg/ga_events
|
55
|
-
licenses:
|
55
|
+
licenses:
|
56
|
+
- MIT
|
56
57
|
metadata: {}
|
57
58
|
post_install_message:
|
58
59
|
rdoc_options: []
|
@@ -62,14 +63,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
63
|
requirements:
|
63
64
|
- - ">="
|
64
65
|
- !ruby/object:Gem::Version
|
65
|
-
version: '
|
66
|
+
version: '2.3'
|
66
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
68
|
requirements:
|
68
69
|
- - ">="
|
69
70
|
- !ruby/object:Gem::Version
|
70
71
|
version: '0'
|
71
72
|
requirements: []
|
72
|
-
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 2.7.6.2
|
73
75
|
signing_key:
|
74
76
|
specification_version: 4
|
75
77
|
summary: This gem allows you to annotate events everywhere in the code of your Rails
|