middleman-google-analytics 0.0.3 → 0.1.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/.gitignore +28 -2
- data/.travis.yml +16 -0
- data/CHANGELOG.md +16 -4
- data/Gemfile +3 -3
- data/LICENSE +17 -17
- data/README.md +60 -29
- data/features/helper.feature +170 -0
- data/features/universal.feature +132 -0
- data/fixtures/test-app-universal/source/index.html.erb +1 -0
- data/fixtures/test-app/source/index.html.erb +1 -0
- data/lib/middleman-google-analytics/extension.rb +18 -2
- data/lib/middleman-google-analytics/version.rb +5 -0
- data/middleman-google-analytics.gemspec +5 -4
- metadata +19 -11
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 12d3bde3081dcdfcc610d145db3e1caf85f33f28
|
|
4
|
+
data.tar.gz: bfeb5cd960ddf072e30634b89ca1a82aaf29c75a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 537f59a5868a5d9c1f05f4617605c163d1096a5fb1b2ab920f821cb44bee5d11032a4e667bc8756c8e5a11f21d4da8c4eb873c21c623fe0851d0cabc74244c4f
|
|
7
|
+
data.tar.gz: e3ff1c37d28ddd8e8c3213de014d5c23f331c7fc2bb9165dca240b2fe19b3718e4ec7379b6287e3e6740c0d617a62e32da78a51293f1bc51f3ec7b376a88b632
|
data/.gitignore
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/test/tmp/
|
|
9
|
+
/test/version_tmp/
|
|
10
|
+
/tmp/
|
|
11
|
+
|
|
12
|
+
## Documentation cache and generated files:
|
|
13
|
+
/.yardoc/
|
|
14
|
+
/_yardoc/
|
|
15
|
+
/doc/
|
|
16
|
+
/rdoc/
|
|
17
|
+
|
|
18
|
+
## Environment normalisation:
|
|
19
|
+
/.bundle/
|
|
20
|
+
/lib/bundler/man/
|
|
21
|
+
|
|
22
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
23
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
2
24
|
Gemfile.lock
|
|
3
|
-
|
|
25
|
+
.ruby-version
|
|
26
|
+
.ruby-gemset
|
|
27
|
+
|
|
28
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
29
|
+
.rvmrc
|
data/.travis.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
language: ruby
|
|
2
|
+
|
|
3
|
+
rvm:
|
|
4
|
+
- 1.9.3
|
|
5
|
+
- 2.0.0
|
|
6
|
+
- 2.1.0
|
|
7
|
+
- jruby-19mode
|
|
8
|
+
|
|
9
|
+
# Bug in jRuby w/ Rouge: https://github.com/jruby/jruby/issues/1392
|
|
10
|
+
matrix:
|
|
11
|
+
allow_failures:
|
|
12
|
+
- rvm: jruby-19mode
|
|
13
|
+
|
|
14
|
+
script: "bundle exec rake test"
|
|
15
|
+
|
|
16
|
+
env: TEST=true
|
data/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## HEAD (???)
|
|
4
|
+
|
|
5
|
+
## 0.1.1 (2014-04-20)
|
|
6
|
+
|
|
7
|
+
* Fix Universal Analytics code.
|
|
8
|
+
|
|
9
|
+
## 0.1.0 (2014-04-16)
|
|
10
|
+
|
|
11
|
+
* Add Cucumber tests.
|
|
12
|
+
* Add Universal Analytics support.
|
|
13
|
+
* Cleanup README.
|
|
14
|
+
|
|
15
|
+
## 0.0.3 (2014-01-07)
|
|
4
16
|
|
|
5
17
|
* Add license info to gemspec.
|
|
6
18
|
* Add project status info to README.
|
|
7
19
|
|
|
8
|
-
## 0.0.2
|
|
20
|
+
## 0.0.2 (2013-10-16)
|
|
9
21
|
|
|
10
22
|
* Remove CDATA markerts that were choking some minifiers.
|
|
11
23
|
* Allow linking of sub-domains to their parent domain.
|
|
@@ -14,6 +26,6 @@
|
|
|
14
26
|
* Implement ability to anonymize IPs.
|
|
15
27
|
* Use asynchronous loading for GA JS.
|
|
16
28
|
|
|
17
|
-
## 0.0.1
|
|
29
|
+
## 0.0.1 (2013-03-10)
|
|
18
30
|
|
|
19
31
|
* Initial version
|
data/Gemfile
CHANGED
|
@@ -10,8 +10,8 @@ group :development do
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
group :test do
|
|
13
|
-
gem "cucumber", "~> 1.
|
|
14
|
-
gem "fivemat"
|
|
15
|
-
gem "aruba", "~> 0.
|
|
13
|
+
gem "cucumber", "~> 1.3.1"
|
|
14
|
+
gem "fivemat", :github => "tpope/fivemat"
|
|
15
|
+
gem "aruba", "~> 0.5.1"
|
|
16
16
|
gem "rspec", "~> 2.7"
|
|
17
17
|
end
|
data/LICENSE
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
+
Copyright (c) 2014 Daniel Bayerlein
|
|
3
4
|
Copyright (c) 2013 Jon Frisby
|
|
4
5
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
the following conditions:
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
12
|
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
|
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
|
14
|
+
all copies or substantial portions of the Software.
|
|
15
15
|
|
|
16
|
-
THE SOFTWARE IS PROVIDED
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
22
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,44 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# middleman-google-analytics
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
[](http://badge.fury.io/rb/middleman-google-analytics)
|
|
4
|
+
[](https://travis-ci.org/danielbayerlein/middleman-google-analytics)
|
|
5
|
+
[](https://gemnasium.com/danielbayerlein/middleman-google-analytics)
|
|
6
6
|
|
|
7
|
+
**middleman-google-analytics** is a [Middleman](http://middlemanapp.com)
|
|
8
|
+
extension that generates
|
|
9
|
+
[Google Analytics](https://www.google.de/intl/en/analytics/) tracking code, and
|
|
10
|
+
keeps your config in `config.rb`, where it belongs.
|
|
7
11
|
|
|
8
|
-
##
|
|
12
|
+
## Installation
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
simple issues will be addressed but I am interested in having a new maintainer take over the
|
|
12
|
-
project for less trivial changes such as adding `analytics.js` support.
|
|
14
|
+
1. Specify the dependency in your project's `Gemfile`:
|
|
13
15
|
|
|
16
|
+
```ruby
|
|
17
|
+
# Gemfile
|
|
18
|
+
gem "middleman-google-analytics"
|
|
19
|
+
```
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
2. Activate the Google Analytics extension in your project's `config.rb`:
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
```ruby
|
|
24
|
+
# config.rb
|
|
25
|
+
activate :google_analytics do |ga|
|
|
26
|
+
ga.tracking_id = 'UA-XXXXXXX-X'
|
|
27
|
+
end
|
|
28
|
+
```
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
3. In your layout, after your footer, call `google_analytics_tag` or
|
|
31
|
+
`google_analytics_universal_tag` and include the results in the page:
|
|
20
32
|
|
|
21
|
-
|
|
22
|
-
# Activate google-analytics extension
|
|
23
|
-
activate :google_analytics do |ga|
|
|
24
|
-
ga.tracking_id = 'UA-XXXXXXX-X'
|
|
25
|
-
end
|
|
26
|
-
```
|
|
33
|
+
**Haml:**
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
```haml
|
|
36
|
+
# Google Analytics
|
|
37
|
+
= google_analytics_tag
|
|
38
|
+
```
|
|
30
39
|
|
|
31
|
-
```haml
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
```haml
|
|
41
|
+
# Universal Analytics
|
|
42
|
+
= google_analytics_universal_tag
|
|
43
|
+
```
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
**ERB:**
|
|
36
46
|
|
|
37
|
-
```erb
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
```erb
|
|
48
|
+
<% # Google Analytics %>
|
|
49
|
+
<%= google_analytics_tag %>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```erb
|
|
53
|
+
<% # Universal Analytics %>
|
|
54
|
+
<%= google_analytics_universal_tag %>
|
|
55
|
+
```
|
|
40
56
|
|
|
41
|
-
|
|
57
|
+
## Configuration
|
|
42
58
|
|
|
43
59
|
```ruby
|
|
44
60
|
activate :google_analytics do |ga|
|
|
@@ -75,8 +91,23 @@ end
|
|
|
75
91
|
Once you've bundled you should be able to run middleman as normal, and have it
|
|
76
92
|
display the GA tracking code.
|
|
77
93
|
|
|
94
|
+
## Special Thanks
|
|
95
|
+
|
|
96
|
+
* [Jon Frisby (@MrJoy)](https://github.com/MrJoy)
|
|
97
|
+
* For the initial code.
|
|
98
|
+
* [Atsushi Nagase (@ngs)](https://github.com/ngs)
|
|
99
|
+
* Cucumber tests and "Universal Analytics" support.
|
|
100
|
+
|
|
101
|
+
## Contributing
|
|
102
|
+
|
|
103
|
+
1. Fork it
|
|
104
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
105
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
106
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
107
|
+
5. Create new [Pull Request](../../pull/new/master)
|
|
108
|
+
|
|
78
109
|
## License
|
|
79
110
|
|
|
80
|
-
Copyright (c)
|
|
111
|
+
Copyright (c) 2014 Daniel Bayerlein. See [LICENSE](./LICENSE) for details.
|
|
81
112
|
|
|
82
|
-
|
|
113
|
+
Copyright (c) 2013 Jon Frisby.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Feature: Google Analytics tag helper
|
|
2
|
+
|
|
3
|
+
Scenario: Basic tracking code
|
|
4
|
+
Given a fixture app "test-app"
|
|
5
|
+
And a file named "config.rb" with:
|
|
6
|
+
"""
|
|
7
|
+
activate :google_analytics do |ga|
|
|
8
|
+
ga.tracking_id = 'UA-123456-78'
|
|
9
|
+
ga.debug = false
|
|
10
|
+
end
|
|
11
|
+
"""
|
|
12
|
+
Given the Server is running at "test-app"
|
|
13
|
+
When I go to "/"
|
|
14
|
+
Then I should see:
|
|
15
|
+
"""
|
|
16
|
+
<script type="text/javascript">
|
|
17
|
+
var _gaq = _gaq || [];
|
|
18
|
+
_gaq.push(["_setAccount", "UA-123456-78"]);
|
|
19
|
+
_gaq.push(["_trackPageview"]);
|
|
20
|
+
(function() {
|
|
21
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
22
|
+
ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
|
|
23
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
24
|
+
})();
|
|
25
|
+
</script>
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
Scenario: On debug mode
|
|
29
|
+
Given a fixture app "test-app"
|
|
30
|
+
And a file named "config.rb" with:
|
|
31
|
+
"""
|
|
32
|
+
activate :google_analytics do |ga|
|
|
33
|
+
ga.tracking_id = 'UA-123456-78'
|
|
34
|
+
ga.debug = true
|
|
35
|
+
end
|
|
36
|
+
"""
|
|
37
|
+
Given the Server is running at "test-app"
|
|
38
|
+
When I go to "/"
|
|
39
|
+
Then I should see:
|
|
40
|
+
"""
|
|
41
|
+
<script type="text/javascript">
|
|
42
|
+
var _gaq = _gaq || [];
|
|
43
|
+
_gaq.push(["_setAccount", "UA-123456-78"]);
|
|
44
|
+
_gaq.push(["_trackPageview"]);
|
|
45
|
+
(function() {
|
|
46
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
47
|
+
ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/u/ga_debug.js';
|
|
48
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
49
|
+
})();
|
|
50
|
+
</script>
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
Scenario: Set domain name
|
|
54
|
+
Given a fixture app "test-app"
|
|
55
|
+
And a file named "config.rb" with:
|
|
56
|
+
"""
|
|
57
|
+
activate :google_analytics do |ga|
|
|
58
|
+
ga.tracking_id = 'UA-123456-78'
|
|
59
|
+
ga.domain_name = 'example.com'
|
|
60
|
+
ga.debug = false
|
|
61
|
+
ga.allow_linker = false
|
|
62
|
+
ga.anonymize_ip = false
|
|
63
|
+
end
|
|
64
|
+
"""
|
|
65
|
+
Given the Server is running at "test-app"
|
|
66
|
+
When I go to "/"
|
|
67
|
+
Then I should see:
|
|
68
|
+
"""
|
|
69
|
+
<script type="text/javascript">
|
|
70
|
+
var _gaq = _gaq || [];
|
|
71
|
+
_gaq.push(["_setAccount", "UA-123456-78"]);
|
|
72
|
+
_gaq.push(["_setDomainName", "example.com"]);
|
|
73
|
+
_gaq.push(["_trackPageview"]);
|
|
74
|
+
(function() {
|
|
75
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
76
|
+
ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
|
|
77
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
78
|
+
})();
|
|
79
|
+
</script>
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
Scenario: Multiple top-level domains
|
|
83
|
+
Given a fixture app "test-app"
|
|
84
|
+
And a file named "config.rb" with:
|
|
85
|
+
"""
|
|
86
|
+
activate :google_analytics do |ga|
|
|
87
|
+
ga.tracking_id = 'UA-123456-78'
|
|
88
|
+
ga.domain_name = 'example.com'
|
|
89
|
+
ga.debug = false
|
|
90
|
+
ga.allow_linker = true
|
|
91
|
+
ga.anonymize_ip = false
|
|
92
|
+
end
|
|
93
|
+
"""
|
|
94
|
+
Given the Server is running at "test-app"
|
|
95
|
+
When I go to "/"
|
|
96
|
+
Then I should see:
|
|
97
|
+
"""
|
|
98
|
+
<script type="text/javascript">
|
|
99
|
+
var _gaq = _gaq || [];
|
|
100
|
+
_gaq.push(["_setAccount", "UA-123456-78"]);
|
|
101
|
+
_gaq.push(["_setDomainName", "example.com"]);
|
|
102
|
+
_gaq.push(["_setAllowLinker", true]);
|
|
103
|
+
_gaq.push(["_trackPageview"]);
|
|
104
|
+
(function() {
|
|
105
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
106
|
+
ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
|
|
107
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
108
|
+
})();
|
|
109
|
+
</script>
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
Scenario: Removing the last octet of the IP address
|
|
113
|
+
Given a fixture app "test-app"
|
|
114
|
+
And a file named "config.rb" with:
|
|
115
|
+
"""
|
|
116
|
+
activate :google_analytics do |ga|
|
|
117
|
+
ga.tracking_id = 'UA-123456-78'
|
|
118
|
+
ga.domain_name = nil
|
|
119
|
+
ga.debug = false
|
|
120
|
+
ga.allow_linker = false
|
|
121
|
+
ga.anonymize_ip = true
|
|
122
|
+
end
|
|
123
|
+
"""
|
|
124
|
+
Given the Server is running at "test-app"
|
|
125
|
+
When I go to "/"
|
|
126
|
+
Then I should see:
|
|
127
|
+
"""
|
|
128
|
+
<script type="text/javascript">
|
|
129
|
+
var _gaq = _gaq || [];
|
|
130
|
+
_gaq.push(["_setAccount", "UA-123456-78"]);
|
|
131
|
+
_gaq.push(["_gat._anonymizeIp"]);
|
|
132
|
+
_gaq.push(["_trackPageview"]);
|
|
133
|
+
(function() {
|
|
134
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
135
|
+
ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
|
|
136
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
137
|
+
})();
|
|
138
|
+
</script>
|
|
139
|
+
"""
|
|
140
|
+
Scenario: Full options
|
|
141
|
+
Given a fixture app "test-app"
|
|
142
|
+
And a file named "config.rb" with:
|
|
143
|
+
"""
|
|
144
|
+
activate :google_analytics do |ga|
|
|
145
|
+
ga.tracking_id = 'UA-123456-78'
|
|
146
|
+
ga.domain_name = 'example.com'
|
|
147
|
+
ga.debug = true
|
|
148
|
+
ga.allow_linker = true
|
|
149
|
+
ga.anonymize_ip = true
|
|
150
|
+
end
|
|
151
|
+
"""
|
|
152
|
+
Given the Server is running at "test-app"
|
|
153
|
+
When I go to "/"
|
|
154
|
+
Then I should see:
|
|
155
|
+
"""
|
|
156
|
+
<script type="text/javascript">
|
|
157
|
+
var _gaq = _gaq || [];
|
|
158
|
+
_gaq.push(["_setAccount", "UA-123456-78"]);
|
|
159
|
+
_gaq.push(["_setDomainName", "example.com"]);
|
|
160
|
+
_gaq.push(["_setAllowLinker", true]);
|
|
161
|
+
_gaq.push(["_gat._anonymizeIp"]);
|
|
162
|
+
_gaq.push(["_trackPageview"]);
|
|
163
|
+
(function() {
|
|
164
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
165
|
+
ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/u/ga_debug.js';
|
|
166
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
167
|
+
})();
|
|
168
|
+
</script>
|
|
169
|
+
"""
|
|
170
|
+
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Feature: Google Analytics universal tag helper
|
|
2
|
+
|
|
3
|
+
Scenario: Basic tracking code
|
|
4
|
+
Given a fixture app "test-app-universal"
|
|
5
|
+
And a file named "config.rb" with:
|
|
6
|
+
"""
|
|
7
|
+
activate :google_analytics do |ga|
|
|
8
|
+
ga.tracking_id = 'UA-123456-78'
|
|
9
|
+
ga.domain_name = nil
|
|
10
|
+
ga.debug = false
|
|
11
|
+
ga.allow_linker = false
|
|
12
|
+
ga.anonymize_ip = false
|
|
13
|
+
end
|
|
14
|
+
"""
|
|
15
|
+
Given the Server is running at "test-app-universal"
|
|
16
|
+
When I go to "/"
|
|
17
|
+
Then I should see:
|
|
18
|
+
"""
|
|
19
|
+
<script type="text/javascript">
|
|
20
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
21
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
22
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
23
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
24
|
+
ga('create', 'UA-123456-78', 'auto');
|
|
25
|
+
ga('send', 'pageview');
|
|
26
|
+
</script>
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
Scenario: Set domain name
|
|
30
|
+
Given a fixture app "test-app-universal"
|
|
31
|
+
And a file named "config.rb" with:
|
|
32
|
+
"""
|
|
33
|
+
activate :google_analytics do |ga|
|
|
34
|
+
ga.tracking_id = 'UA-123456-78'
|
|
35
|
+
ga.domain_name = 'example.com'
|
|
36
|
+
ga.debug = false
|
|
37
|
+
ga.allow_linker = false
|
|
38
|
+
ga.anonymize_ip = false
|
|
39
|
+
end
|
|
40
|
+
"""
|
|
41
|
+
Given the Server is running at "test-app-universal"
|
|
42
|
+
When I go to "/"
|
|
43
|
+
Then I should see:
|
|
44
|
+
"""
|
|
45
|
+
<script type="text/javascript">
|
|
46
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
47
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
48
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
49
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
50
|
+
ga('create', 'UA-123456-78', 'example.com');
|
|
51
|
+
ga('send', 'pageview');
|
|
52
|
+
</script>
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
Scenario: Multiple top-level domains
|
|
56
|
+
Given a fixture app "test-app-universal"
|
|
57
|
+
And a file named "config.rb" with:
|
|
58
|
+
"""
|
|
59
|
+
activate :google_analytics do |ga|
|
|
60
|
+
ga.tracking_id = 'UA-123456-78'
|
|
61
|
+
ga.domain_name = 'example.com'
|
|
62
|
+
ga.debug = false
|
|
63
|
+
ga.allow_linker = true
|
|
64
|
+
ga.anonymize_ip = false
|
|
65
|
+
end
|
|
66
|
+
"""
|
|
67
|
+
Given the Server is running at "test-app-universal"
|
|
68
|
+
When I go to "/"
|
|
69
|
+
Then I should see:
|
|
70
|
+
"""
|
|
71
|
+
<script type="text/javascript">
|
|
72
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
73
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
74
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
75
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
76
|
+
ga('create', 'UA-123456-78', 'example.com', {'allowLinker': true});
|
|
77
|
+
ga('send', 'pageview');
|
|
78
|
+
</script>
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
Scenario: Removing the last octet of the IP address
|
|
82
|
+
Given a fixture app "test-app-universal"
|
|
83
|
+
And a file named "config.rb" with:
|
|
84
|
+
"""
|
|
85
|
+
activate :google_analytics do |ga|
|
|
86
|
+
ga.tracking_id = 'UA-123456-78'
|
|
87
|
+
ga.domain_name = nil
|
|
88
|
+
ga.debug = false
|
|
89
|
+
ga.allow_linker = false
|
|
90
|
+
ga.anonymize_ip = true
|
|
91
|
+
end
|
|
92
|
+
"""
|
|
93
|
+
Given the Server is running at "test-app-universal"
|
|
94
|
+
When I go to "/"
|
|
95
|
+
Then I should see:
|
|
96
|
+
"""
|
|
97
|
+
<script type="text/javascript">
|
|
98
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
99
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
100
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
101
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
102
|
+
ga('create', 'UA-123456-78', 'auto');
|
|
103
|
+
ga('set', 'anonymizeIp', true);
|
|
104
|
+
ga('send', 'pageview');
|
|
105
|
+
</script>
|
|
106
|
+
"""
|
|
107
|
+
Scenario: Full options
|
|
108
|
+
Given a fixture app "test-app-universal"
|
|
109
|
+
And a file named "config.rb" with:
|
|
110
|
+
"""
|
|
111
|
+
activate :google_analytics do |ga|
|
|
112
|
+
ga.tracking_id = 'UA-123456-78'
|
|
113
|
+
ga.domain_name = 'example.com'
|
|
114
|
+
ga.debug = true
|
|
115
|
+
ga.allow_linker = true
|
|
116
|
+
ga.anonymize_ip = true
|
|
117
|
+
end
|
|
118
|
+
"""
|
|
119
|
+
Given the Server is running at "test-app-universal"
|
|
120
|
+
When I go to "/"
|
|
121
|
+
Then I should see:
|
|
122
|
+
"""
|
|
123
|
+
<script type="text/javascript">
|
|
124
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
125
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
126
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
127
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
128
|
+
ga('create', 'UA-123456-78', 'example.com', {'allowLinker': true});
|
|
129
|
+
ga('set', 'anonymizeIp', true);
|
|
130
|
+
ga('send', 'pageview');
|
|
131
|
+
</script>
|
|
132
|
+
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= google_analytics_universal_tag %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= google_analytics_tag %>
|
|
@@ -24,11 +24,9 @@ module Middleman
|
|
|
24
24
|
module InstanceMethods
|
|
25
25
|
def google_analytics_tag
|
|
26
26
|
options = ::Middleman::GoogleAnalytics.options
|
|
27
|
-
|
|
28
27
|
options.debug = development? if options.debug.nil?
|
|
29
28
|
ga = options.debug ? 'u/ga_debug' : 'ga'
|
|
30
29
|
domain_name = options.domain_name
|
|
31
|
-
|
|
32
30
|
if tracking_id = options.tracking_id
|
|
33
31
|
gaq = []
|
|
34
32
|
gaq << ['_setAccount', "#{tracking_id}"]
|
|
@@ -44,6 +42,24 @@ module Middleman
|
|
|
44
42
|
ga.src = ('https:' == document.location.protocol ? '//ssl' : '//www') + '.google-analytics.com/#{ga}.js';
|
|
45
43
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
46
44
|
})();
|
|
45
|
+
</script>}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def google_analytics_universal_tag
|
|
50
|
+
options = ::Middleman::GoogleAnalytics.options
|
|
51
|
+
options.debug = development? if options.debug.nil?
|
|
52
|
+
ga = options.debug ? 'u/ga_debug' : 'ga'
|
|
53
|
+
domain_name = options.domain_name
|
|
54
|
+
if tracking_id = options.tracking_id
|
|
55
|
+
%Q{<script type="text/javascript">
|
|
56
|
+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
57
|
+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
58
|
+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
59
|
+
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
|
60
|
+
ga('create', '#{ tracking_id }', '#{ domain_name || 'auto' }'#{ options.allow_linker ? ", {'allowLinker': true}" : '' });#{
|
|
61
|
+
options.anonymize_ip ? "\n ga('set', 'anonymizeIp', true);" : '' }
|
|
62
|
+
ga('send', 'pageview');
|
|
47
63
|
</script>}
|
|
48
64
|
end
|
|
49
65
|
end
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "middleman-google-analytics/version"
|
|
3
4
|
|
|
4
5
|
Gem::Specification.new do |s|
|
|
5
6
|
s.name = "middleman-google-analytics"
|
|
6
|
-
s.version =
|
|
7
|
+
s.version = Middleman::GoogleAnalytics::VERSION
|
|
7
8
|
s.platform = Gem::Platform::RUBY
|
|
8
|
-
s.authors = ["Jon Frisby"]
|
|
9
|
-
s.email = ["jfrisby@mrjoy.com"]
|
|
10
|
-
s.homepage = "
|
|
9
|
+
s.authors = ["Daniel Bayerlein", "Jon Frisby"]
|
|
10
|
+
s.email = ["daniel.bayerlein@googlemail.com", "jfrisby@mrjoy.com"]
|
|
11
|
+
s.homepage = "https://github.com/danielbayerlein/middleman-google-analytics"
|
|
11
12
|
s.summary = %q{A Middleman plugin for handling Google Analytics tracking code.}
|
|
12
13
|
s.license = "MIT"
|
|
13
14
|
# s.description = %q{A longer description of your extension}
|
metadata
CHANGED
|
@@ -1,50 +1,56 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: middleman-google-analytics
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
+
- Daniel Bayerlein
|
|
7
8
|
- Jon Frisby
|
|
8
9
|
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
12
|
+
date: 2014-04-20 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: middleman-core
|
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
|
16
17
|
requirements:
|
|
17
|
-
- -
|
|
18
|
+
- - ">="
|
|
18
19
|
- !ruby/object:Gem::Version
|
|
19
20
|
version: 3.0.6
|
|
20
21
|
type: :runtime
|
|
21
22
|
prerelease: false
|
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
24
|
requirements:
|
|
24
|
-
- -
|
|
25
|
+
- - ">="
|
|
25
26
|
- !ruby/object:Gem::Version
|
|
26
27
|
version: 3.0.6
|
|
27
28
|
description:
|
|
28
29
|
email:
|
|
30
|
+
- daniel.bayerlein@googlemail.com
|
|
29
31
|
- jfrisby@mrjoy.com
|
|
30
32
|
executables: []
|
|
31
33
|
extensions: []
|
|
32
34
|
extra_rdoc_files: []
|
|
33
35
|
files:
|
|
34
|
-
- .gitignore
|
|
35
|
-
- .
|
|
36
|
-
- .ruby-version
|
|
36
|
+
- ".gitignore"
|
|
37
|
+
- ".travis.yml"
|
|
37
38
|
- CHANGELOG.md
|
|
38
39
|
- Gemfile
|
|
39
40
|
- LICENSE
|
|
40
41
|
- README.md
|
|
41
42
|
- Rakefile
|
|
43
|
+
- features/helper.feature
|
|
42
44
|
- features/support/env.rb
|
|
45
|
+
- features/universal.feature
|
|
46
|
+
- fixtures/test-app-universal/source/index.html.erb
|
|
47
|
+
- fixtures/test-app/source/index.html.erb
|
|
43
48
|
- lib/middleman-google-analytics.rb
|
|
44
49
|
- lib/middleman-google-analytics/extension.rb
|
|
50
|
+
- lib/middleman-google-analytics/version.rb
|
|
45
51
|
- lib/middleman_extension.rb
|
|
46
52
|
- middleman-google-analytics.gemspec
|
|
47
|
-
homepage:
|
|
53
|
+
homepage: https://github.com/danielbayerlein/middleman-google-analytics
|
|
48
54
|
licenses:
|
|
49
55
|
- MIT
|
|
50
56
|
metadata: {}
|
|
@@ -54,20 +60,22 @@ require_paths:
|
|
|
54
60
|
- lib
|
|
55
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
62
|
requirements:
|
|
57
|
-
- -
|
|
63
|
+
- - ">="
|
|
58
64
|
- !ruby/object:Gem::Version
|
|
59
65
|
version: '0'
|
|
60
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
67
|
requirements:
|
|
62
|
-
- -
|
|
68
|
+
- - ">="
|
|
63
69
|
- !ruby/object:Gem::Version
|
|
64
70
|
version: '0'
|
|
65
71
|
requirements: []
|
|
66
72
|
rubyforge_project:
|
|
67
|
-
rubygems_version: 2.
|
|
73
|
+
rubygems_version: 2.2.2
|
|
68
74
|
signing_key:
|
|
69
75
|
specification_version: 4
|
|
70
76
|
summary: A Middleman plugin for handling Google Analytics tracking code.
|
|
71
77
|
test_files:
|
|
78
|
+
- features/helper.feature
|
|
72
79
|
- features/support/env.rb
|
|
80
|
+
- features/universal.feature
|
|
73
81
|
has_rdoc:
|
data/.ruby-gemset
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
middleman-google-analytics
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ruby-2.0.0-p247
|