split-analytics 1.0.0 → 1.0.1
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 +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +1 -1
- data/Readme.md +9 -5
- data/lib/split/analytics.rb +12 -11
- data/lib/split/analytics/version.rb +1 -1
- data/spec/analytics_spec.rb +7 -5
- data/spec/spec_helper.rb +4 -0
- data/split-analytics.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37226a44a019f3dfdb48e667631cc012389cc588
|
4
|
+
data.tar.gz: 2dd4cb0f15a3cfa437d8cc003947c91ac38f14c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 428b4424100c1285bf16814e04911c0514d1336cbacd731c5fb24c3bb0e29adea3938e013d622f8286d2e4460142f57e8f1ee21680e1a4d1e10c2cfd80266e39
|
7
|
+
data.tar.gz: f044584b79505ca14a492881bdc6797e0f0b0158407d474f21a175cd3333b53955bb176558006abde7e646d609701587b8ecf90dd6de6966180b8b71c76d4975
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Readme.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
# Split
|
1
|
+
# [Split Analytics](http://libraries.io/rubygems/split-analytics)
|
2
2
|
|
3
|
-
An extension to [Split](http://github.com/
|
3
|
+
An extension to [Split](http://github.com/splitrb/split) to push test data to google analytics.
|
4
|
+
|
5
|
+
[](http://travis-ci.org/andrew/split-analytics)
|
6
|
+
[](http://badge.fury.io/rb/split-analytics)
|
7
|
+
[](https://gemnasium.com/andrew/split-analytics)
|
4
8
|
|
5
9
|
## Requirements
|
6
10
|
|
@@ -52,7 +56,7 @@ haml example:
|
|
52
56
|
|
53
57
|
See [Google Analytics Tracking Methods](https://developers.google.com/analytics/devguides/collection/gajs/methods/) for available options.
|
54
58
|
|
55
|
-
```
|
59
|
+
```ruby
|
56
60
|
tracker_methods = {
|
57
61
|
:setDomainName => "example.com", # String argument
|
58
62
|
:setAllowLinker => true, # Boolean argument
|
@@ -90,8 +94,8 @@ haml example:
|
|
90
94
|
|
91
95
|
## Development
|
92
96
|
|
93
|
-
Source hosted at [GitHub](http://github.com/
|
94
|
-
Report Issues/Feature requests on [GitHub Issues](http://github.com/
|
97
|
+
Source hosted at [GitHub](http://github.com/splitrb/split-analytics).
|
98
|
+
Report Issues/Feature requests on [GitHub Issues](http://github.com/splitrb/split-analytics/issues).
|
95
99
|
|
96
100
|
Tests can be ran with `rake spec`
|
97
101
|
|
data/lib/split/analytics.rb
CHANGED
@@ -15,10 +15,10 @@ module Split
|
|
15
15
|
code = <<-EOF
|
16
16
|
<script type="text/javascript">
|
17
17
|
var _gaq = _gaq || [];
|
18
|
-
_gaq.push([
|
18
|
+
_gaq.push(["_setAccount", "#{account}"]);
|
19
19
|
#{insert_tracker_methods(tracker_methods)}
|
20
20
|
#{custom_variables}
|
21
|
-
_gaq.push([
|
21
|
+
_gaq.push(["_trackPageview"]);
|
22
22
|
(function() {
|
23
23
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
24
24
|
ga.src = ('https:' == document.location.protocol ? '#{ssl_tracker_url}' : '#{tracker_url}');
|
@@ -31,10 +31,11 @@ module Split
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def custom_variables
|
34
|
-
return nil if
|
34
|
+
return nil if session.nil?
|
35
35
|
arr = []
|
36
|
-
|
37
|
-
|
36
|
+
|
37
|
+
session.each_with_index do |h, i|
|
38
|
+
arr << "_gaq.push([\"_setCustomVar\", #{i + 1}, \"#{h[0]}\", \"#{h[1]}\", 1]);"
|
38
39
|
end
|
39
40
|
arr.reverse[0..4].reverse.join("\n")
|
40
41
|
end
|
@@ -47,22 +48,22 @@ module Split
|
|
47
48
|
tracker_methods.each do |k, v|
|
48
49
|
if v.class == String && v.empty?
|
49
50
|
# No argument tracker method
|
50
|
-
arr << "_gaq.push([
|
51
|
+
arr << "_gaq.push([\"" + "_" + "#{k}\"]);"
|
51
52
|
else
|
52
53
|
case v
|
53
54
|
when String
|
54
55
|
# String argument tracker method
|
55
|
-
arr << "_gaq.push([
|
56
|
+
arr << "_gaq.push([\"" + '_' + "#{k}\", \"#{v}\"]);"
|
56
57
|
when TrueClass
|
57
58
|
# Boolean argument tracker method
|
58
|
-
arr << "_gaq.push([
|
59
|
+
arr << "_gaq.push([\"" + '_' + "#{k}\", #{v}]);"
|
59
60
|
when FalseClass
|
60
61
|
# Boolean argument tracker method
|
61
|
-
arr << "_gaq.push([
|
62
|
+
arr << "_gaq.push([\"" + '_' + "#{k}\", #{v}]);"
|
62
63
|
when Array
|
63
64
|
# Array argument tracker method
|
64
|
-
values = v.map { |value| "
|
65
|
-
arr << "_gaq.push([
|
65
|
+
values = v.map { |value| "\"#{value}\"" }.join(', ')
|
66
|
+
arr << "_gaq.push([\"" + '_' + "#{k}\", #{values}]);"
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
data/spec/analytics_spec.rb
CHANGED
@@ -4,7 +4,7 @@ describe Split::Analytics do
|
|
4
4
|
include Split::Helper
|
5
5
|
it 'should generate valid analytics javascript' do
|
6
6
|
tracking_code = tracking_code(account: 'UA-12345-6')
|
7
|
-
expect(tracking_code).to eql(
|
7
|
+
expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n \n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should generate valid analytics javascript with arbitrary tracker object methods' do
|
@@ -14,18 +14,20 @@ describe Split::Analytics do
|
|
14
14
|
clearOrganic: '' # No argument
|
15
15
|
}
|
16
16
|
tracking_code = tracking_code(:account => 'UA-12345-6', :tracker_methods => tracker_methods)
|
17
|
-
expect(tracking_code).to eql(
|
17
|
+
expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n _gaq.push(["_setDomainName", "example.com"]);\n_gaq.push(["_setAllowLinker", true]);\n_gaq.push(["_clearOrganic"]);\n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should add custom variables for every test the user is involved in' do
|
21
21
|
first_alt = ab_test('link_colour', 'red', 'blue')
|
22
22
|
|
23
|
+
expect(session).to eql({'link_colour' => first_alt})
|
24
|
+
|
23
25
|
tracking_code = tracking_code(account: 'UA-12345-6')
|
24
|
-
expect(tracking_code).to eql(
|
26
|
+
expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n \n _gaq.push(["_setCustomVar", 1, "link_colour", "#{first_alt}", 1]);\n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://ssl.google-analytics.com/ga.js' : 'http://www.google-analytics.com/ga.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
|
25
27
|
end
|
26
28
|
|
27
29
|
it 'uses doubleclick as tracker url' do
|
28
|
-
tracking_code = tracking_code(account:
|
29
|
-
expect(tracking_code).to eql(
|
30
|
+
tracking_code = tracking_code(account: "UA-12345-6", tracker_url: 'stats.g.doubleclick.net/dc.js', :ssl_tracker_url => 'stats.g.doubleclick.net/dc.js')
|
31
|
+
expect(tracking_code).to eql(%Q{ <script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(["_setAccount", "UA-12345-6"]);\n \n \n _gaq.push(["_trackPageview"]);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n ga.src = ('https:' == document.location.protocol ? 'https://stats.g.doubleclick.net/dc.js' : 'http://stats.g.doubleclick.net/dc.js');\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n </script>\n})
|
30
32
|
end
|
31
33
|
end
|
data/spec/spec_helper.rb
CHANGED
data/split-analytics.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.authors = ['Andrew Nesbitt']
|
7
7
|
gem.email = ['andrewnez@gmail.com']
|
8
8
|
gem.summary = 'Split extension to push test data to google analytics'
|
9
|
-
gem.homepage = 'https://github.com/
|
9
|
+
gem.homepage = 'https://github.com/splitrb/split-analytics'
|
10
10
|
gem.license = 'MIT'
|
11
11
|
|
12
12
|
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: split-analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: split
|
@@ -70,7 +70,7 @@ files:
|
|
70
70
|
- spec/analytics_spec.rb
|
71
71
|
- spec/spec_helper.rb
|
72
72
|
- split-analytics.gemspec
|
73
|
-
homepage: https://github.com/
|
73
|
+
homepage: https://github.com/splitrb/split-analytics
|
74
74
|
licenses:
|
75
75
|
- MIT
|
76
76
|
metadata: {}
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.5.1
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Split extension to push test data to google analytics
|