garails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -17,7 +17,8 @@ and run 'bundle install'.
17
17
  Then create a config/initializers/garails.rb with the following content:
18
18
 
19
19
  Garails.ga_account = 'UA-12345678-9'
20
- # Garails.ga_domain = '.mydomain.com'
20
+ # Garails.ga_cookie_domain = '.mydomain.com'
21
+ # Garails.ga_hostname = 'www.mydomain.com'
21
22
 
22
23
  == Usage
23
24
 
@@ -31,7 +31,9 @@ class Garails::GoogleAnalyticsController < ApplicationController
31
31
 
32
32
  def extract_visitor_id
33
33
  @visitor_id = cookies[UTM_COOKIE_NAME] || construct_new_visitor_id
34
- cookies[UTM_COOKIE_NAME] = {:value => @visitor_id, :expires => Time.now + 2.years, :path => '/'}
34
+ cookie_data = {:value => @visitor_id, :expires => Time.now + 2.years, :path => '/'}
35
+ cookie_data[:domain] = Garails.ga_cookie_domain unless Garails.ga_cookie_domain.blank?
36
+ cookies[UTM_COOKIE_NAME] = cookie_data
35
37
  end
36
38
 
37
39
  def construct_new_visitor_id
@@ -1,6 +1,6 @@
1
1
  module Garails::JavascriptHelper
2
2
  def google_analytics_tracking_javascript
3
- return "" if Garails.ga_account.blank?
3
+ return "" unless Garails.ga_setup?
4
4
  render :template => "garails/google_analytics"
5
5
  end
6
6
  end
@@ -2,8 +2,8 @@
2
2
  //<![CDATA[
3
3
  var _gaq = _gaq || [];
4
4
  _gaq.push(['_setAccount', '<%= Garails.ga_account %>']);
5
- <% unless Garails.ga_domain.blank? -%>
6
- _gaq.push(['_setDomainName', '<%= Garails.ga_domain %>']);
5
+ <% unless Garails.ga_cookie_domain.blank? -%>
6
+ _gaq.push(['_setDomainName', '<%= Garails.ga_cookie_domain %>']);
7
7
  <% end -%>
8
8
  _gaq.push(['_trackPageview']);
9
9
  (function() {
data/garails.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = 'Michael Reinsch'
10
10
  s.email = "michael@mobalean.com"
11
- s.homepage = ""
11
+ s.homepage = "http://github.com/mreinsch/garails"
12
12
  s.description = "Google Analytics for Rails"
13
13
  s.summary = "Google Analytics for Rails"
14
14
 
@@ -1,3 +1,3 @@
1
1
  module Garails
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/garails.rb CHANGED
@@ -4,10 +4,16 @@ module Garails
4
4
  mattr_accessor :ga_account
5
5
  @@ga_account = nil
6
6
 
7
- # domain setting. Only set this if you need to (e.g. for subdomain tracking).
8
- # Corresponds to "_setDomainName".
9
- mattr_accessor :ga_domain
10
- @@ga_domain = nil
7
+ # cookie domain for the tracking cookie. Only set this if you need to
8
+ # (e.g. for subdomain tracking). Corresponds to "_setDomainName".
9
+ mattr_accessor :ga_cookie_domain
10
+ @@ga_cookie_domain = nil
11
+
12
+ # the host name (such as www.example.com). This is usually derived from the
13
+ # incoming request. Set it here if you want to enable tracking outside your
14
+ # controllers or views.
15
+ mattr_accessor :ga_hostname
16
+ @@ga_hostname = nil
11
17
 
12
18
  def self.ga_setup?
13
19
  ! Garails.ga_account.blank?
@@ -26,13 +32,10 @@ module Garails
26
32
  end
27
33
 
28
34
  def self.create_gabba(account, request, opts = {})
29
- Gabbara::Gabba.new(account, Garails.ga_domain, opts).tap do |g|
30
- g.logger = Rails.logger
31
- g.request = request
32
- end
35
+ opts = opts.reverse_merge(:request => request, :logger => Rails.logger)
36
+ Gabbara::Gabba.new(account, Garails.ga_hostname, opts)
33
37
  end
34
38
  end
35
39
 
36
40
  require 'garails/version'
37
41
  require 'garails/engine'
38
-
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Reinsch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-20 00:00:00 +09:00
18
+ date: 2010-12-21 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -58,7 +58,7 @@ files:
58
58
  - lib/garails/engine.rb
59
59
  - lib/garails/version.rb
60
60
  has_rdoc: true
61
- homepage: ""
61
+ homepage: http://github.com/mreinsch/garails
62
62
  licenses: []
63
63
 
64
64
  post_install_message: