Class: GoogleAnalytics::Events::TrackPageview

Inherits:
GoogleAnalytics::Event show all
Defined in:
lib/google-analytics/events/events.rb

Overview

Instance Attribute Summary

Attributes inherited from GoogleAnalytics::Event

#action, #name, #params

Instance Method Summary collapse

Methods inherited from GoogleAnalytics::Event

#single_event?

Constructor Details

#initialize(opts = {}) ⇒ TrackPageview

Returns a new instance of TrackPageview.

Parameters:

  • page (String)

    optional virtual pageview tracking

See Also:



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/google-analytics/events/events.rb', line 75

def initialize(opts = {})
  # Just use default pageview if no page was given
  if opts.is_a?(Hash) && opts.fetch(:page, nil) == nil
    super('send', 'pageview')
  # Provide only the page string if a title was not given but a page was
  elsif opts.is_a?(Hash) && opts.fetch(:page, false)
    super('send', 'pageview', opts.fetch(:title, false) ? opts : opts[:page])
  # Print out a JSON Value for the pageview
  else
    super('send', 'pageview', opts)
  end
end