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.
-
#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_utmz ⇒ Object
- #utma? ⇒ Boolean
- #utmz? ⇒ Boolean
Constructor Details
#initialize(cookies = {}) ⇒ GaCookieParser
Returns a new instance of GaCookieParser.
12 13 14 15 16 |
# File 'lib/ga_cookie_parser.rb', line 12 def initialize( = {}) @utmz = [:utmz] @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 |
#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
26 27 28 29 |
# File 'lib/ga_cookie_parser.rb', line 26 def parse_utmz parse_utma end |
#parse_utma ⇒ Object
48 49 50 51 52 |
# File 'lib/ga_cookie_parser.rb', line 48 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_utmz ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ga_cookie_parser.rb', line 31 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
22 23 24 |
# File 'lib/ga_cookie_parser.rb', line 22 def utma? !(@utma.nil? || @utma.empty?) end |
#utmz? ⇒ Boolean
18 19 20 |
# File 'lib/ga_cookie_parser.rb', line 18 def utmz? !(@utmz.nil? || @utmz.empty?) end |