google-analytics-rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.markdown
CHANGED
data/README.markdown
CHANGED
@@ -38,7 +38,7 @@ With DoubleClick instead of vanilla Google Analytics script
|
|
38
38
|
|
39
39
|
# replace this with your tracker code
|
40
40
|
GA.tracker = "UA-xxxxxx-x"
|
41
|
-
GA.
|
41
|
+
GA.script_source = "('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'"
|
42
42
|
|
43
43
|
`app/views/layout/application.html.erb`, in the `<head>` tag :
|
44
44
|
|
@@ -20,6 +20,12 @@ module GoogleAnalytics
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
class Require < Event
|
24
|
+
def initialize(name, url)
|
25
|
+
super('_require', name, url)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
23
29
|
class SetSiteSpeedSampleRate < Event
|
24
30
|
# @param sample_rate [Integer] the percentage of page views that should be used
|
25
31
|
# for page speed metrics - defaults to 1 (aka 1%) if the event is missing.
|
@@ -52,7 +52,7 @@ module GoogleAnalytics::Rails
|
|
52
52
|
#
|
53
53
|
# @param options [Hash]
|
54
54
|
# @option options [Boolean] :local (false) Sets the local development mode.
|
55
|
-
# See http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=741739888e14c07a&hl=en
|
55
|
+
# See {http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=741739888e14c07a&hl=en}
|
56
56
|
# @option options [Array, GoogleAnalytics::Event] :add_events ([])
|
57
57
|
# The page views are tracked by default, additional events can be added here.
|
58
58
|
# @option options [String] :page
|
@@ -65,6 +65,9 @@ module GoogleAnalytics::Rails
|
|
65
65
|
# Whether to anonymize the visitor ip or not.
|
66
66
|
# This is required for european websites and actively enforced for german ones,
|
67
67
|
# see {GoogleAnalytics::Events::AnonymizeIp}.
|
68
|
+
# @option options [Boolean] :enhanced_link_attribution
|
69
|
+
# See separate information for multiple links on a page that all have the same destination,
|
70
|
+
# see {https://support.google.com/analytics/answer/2558867}.
|
68
71
|
#
|
69
72
|
# @example Set the local bit in development mode
|
70
73
|
# analytics_init :local => Rails.env.development?
|
@@ -82,6 +85,7 @@ module GoogleAnalytics::Rails
|
|
82
85
|
|
83
86
|
local = options.delete(:local) || false
|
84
87
|
anonymize = options.delete(:anonymize) || false
|
88
|
+
link_attribution = options.delete(:enhanced_link_attribution) || false
|
85
89
|
domain = options.delete(:domain) || (local ? "none" : "auto")
|
86
90
|
events = options.delete(:add_events) || []
|
87
91
|
events = [events] unless events.is_a?(Array)
|
@@ -97,7 +101,10 @@ module GoogleAnalytics::Rails
|
|
97
101
|
events.unshift GA::Events::SetAllowLinker.new(true)
|
98
102
|
end
|
99
103
|
events.unshift GA::Events::SetAccount.new(tracker)
|
100
|
-
|
104
|
+
events.unshift GA::Events::Require.new(
|
105
|
+
'inpage_linkid',
|
106
|
+
'//www.google-analytics.com/plugins/ga/inpage_linkid.js'
|
107
|
+
) if link_attribution
|
101
108
|
|
102
109
|
events.each do |event|
|
103
110
|
queue << event
|
@@ -114,6 +114,25 @@ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga
|
|
114
114
|
assert_equal(VALID_INIT_WITH_ANONYMIZED_IP, analytics_init(:anonymize => true))
|
115
115
|
end
|
116
116
|
|
117
|
+
VALID_INIT_WITH_LINK_ATTRIBUTION = <<-JAVASCRIPT
|
118
|
+
<script type="text/javascript">
|
119
|
+
var _gaq = _gaq || [];
|
120
|
+
_gaq.push(['_require','inpage_linkid','//www.google-analytics.com/plugins/ga/inpage_linkid.js']);
|
121
|
+
_gaq.push(['_setAccount','TEST']);
|
122
|
+
_gaq.push(['_setDomainName','auto']);
|
123
|
+
_gaq.push(['_trackPageview']);
|
124
|
+
(function() {
|
125
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
126
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
127
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
128
|
+
})();
|
129
|
+
</script>
|
130
|
+
JAVASCRIPT
|
131
|
+
|
132
|
+
def test_analytics_init_with_link_attribution
|
133
|
+
assert_equal(VALID_INIT_WITH_LINK_ATTRIBUTION, analytics_init(:enhanced_link_attribution => true))
|
134
|
+
end
|
135
|
+
|
117
136
|
VALID_EVENT_INIT = <<-JAVASCRIPT
|
118
137
|
<script type="text/javascript">
|
119
138
|
var _gaq = _gaq || [];
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-analytics-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -121,7 +121,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
segments:
|
123
123
|
- 0
|
124
|
-
hash:
|
124
|
+
hash: 3614566111248064777
|
125
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
126
|
none: false
|
127
127
|
requirements:
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
130
|
version: '0'
|
131
131
|
segments:
|
132
132
|
- 0
|
133
|
-
hash:
|
133
|
+
hash: 3614566111248064777
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project: google-analytics-rails
|
136
136
|
rubygems_version: 1.8.24
|