Class: GaCookieParser::GaCookieParser
- Inherits:
-
Object
- Object
- GaCookieParser::GaCookieParser
- Defined in:
- lib/ga_cookie_parser.rb
Instance Attribute Summary collapse
-
#utma ⇒ Object
readonly
Returns the value of attribute utma.
-
#utma_hash ⇒ Object
readonly
Returns the value of attribute utma_hash.
-
#utmb ⇒ Object
readonly
Returns the value of attribute utmb.
-
#utmb_hash ⇒ Object
readonly
Returns the value of attribute utmb_hash.
-
#utmz ⇒ Object
readonly
Returns the value of attribute utmz.
-
#utmz_hash ⇒ Object
readonly
Returns the value of attribute utmz_hash.
Instance Method Summary collapse
-
#initialize(cookies = {}) ⇒ GaCookieParser
constructor
A new instance of GaCookieParser.
- #parse_cookies ⇒ Object
- #parse_utma ⇒ Object
- #parse_utmb ⇒ Object
- #parse_utmz ⇒ Object
- #utma? ⇒ Boolean
- #utmb? ⇒ Boolean
- #utmz? ⇒ Boolean
Constructor Details
#initialize(cookies = {}) ⇒ GaCookieParser
Returns a new instance of GaCookieParser.
12 13 14 15 16 17 |
# File 'lib/ga_cookie_parser.rb', line 12 def initialize( = {}) @utmz = [:utmz] @utmb = [:utmb] @utma = [:utma] end |
Instance Attribute Details
#utma ⇒ Object (readonly)
Returns the value of attribute utma.
10 11 12 |
# File 'lib/ga_cookie_parser.rb', line 10 def utma @utma end |
#utma_hash ⇒ Object (readonly)
Returns the value of attribute utma_hash.
10 11 12 |
# File 'lib/ga_cookie_parser.rb', line 10 def utma_hash @utma_hash end |
#utmb ⇒ Object (readonly)
Returns the value of attribute utmb.
10 11 12 |
# File 'lib/ga_cookie_parser.rb', line 10 def utmb @utmb end |
#utmb_hash ⇒ Object (readonly)
Returns the value of attribute utmb_hash.
10 11 12 |
# File 'lib/ga_cookie_parser.rb', line 10 def utmb_hash @utmb_hash end |
#utmz ⇒ Object (readonly)
Returns the value of attribute utmz.
10 11 12 |
# File 'lib/ga_cookie_parser.rb', line 10 def utmz @utmz end |
#utmz_hash ⇒ Object (readonly)
Returns the value of attribute utmz_hash.
10 11 12 |
# File 'lib/ga_cookie_parser.rb', line 10 def utmz_hash @utmz_hash end |
Instance Method Details
#parse_cookies ⇒ Object
31 32 33 34 35 |
# File 'lib/ga_cookie_parser.rb', line 31 def parse_utmz parse_utmb parse_utma end |
#parse_utma ⇒ Object
60 61 62 63 64 |
# File 'lib/ga_cookie_parser.rb', line 60 def parse_utma return if (@utma.nil? || @utma.empty?) @utma_hash = h = {} h[:domain_hash], h[:visitor_id], h[:initial_visit_at], h[:previous_visit_at], h[:current_visit_at], h[:session_counter] = @utma.split(".") end |
#parse_utmb ⇒ Object
54 55 56 57 58 |
# File 'lib/ga_cookie_parser.rb', line 54 def parse_utmb return if (@utmb.nil? || @utmb.empty?) @utmb_hash = h = {} h[:domain_hash], h[:pageview], h[:outbound_click], h[:timestamp] = @utmb.split(".") end |
#parse_utmz ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ga_cookie_parser.rb', line 37 def parse_utmz return if (@utmz.nil? || @utmz.empty?) @utmz_hash = h = {} h[:domain_hash], h[:timestamp], h[:session_counter], h[:campaign_number], kv_pairs = @utmz.split(".", 5) kv_pairs && kv_pairs.split("|").each do |pair| k, v = pair.split("=") h[k.to_sym] = v if k && v end if h[:utmgclid] h[:utmcsr] = 'google' h[:utmcmd] = 'cpc' end end |
#utma? ⇒ Boolean
27 28 29 |
# File 'lib/ga_cookie_parser.rb', line 27 def utma? !(@utma.nil? || @utma.empty?) end |
#utmb? ⇒ Boolean
23 24 25 |
# File 'lib/ga_cookie_parser.rb', line 23 def utmb? !(@utmb.nil? || @utmb.empty?) end |
#utmz? ⇒ Boolean
19 20 21 |
# File 'lib/ga_cookie_parser.rb', line 19 def utmz? !(@utmz.nil? || @utmz.empty?) end |