Class: Matomo::Referrer
- Inherits:
-
Object
- Object
- Matomo::Referrer
- Defined in:
- lib/matomo.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
Returns the value of attribute label.
-
#visits ⇒ Object
Returns the value of attribute visits.
Class Method Summary collapse
Instance Method Summary collapse
- #actions_per_visit ⇒ Object
-
#initialize(params = {}) ⇒ Referrer
constructor
A new instance of Referrer.
Constructor Details
#initialize(params = {}) ⇒ Referrer
Returns a new instance of Referrer.
11 12 13 14 15 |
# File 'lib/matomo.rb', line 11 def initialize(params = {}) @label = params["label"] @visits = params["nb_visits"] || 0 @actions = params["nb_actions"] || 0 end |
Instance Attribute Details
#label ⇒ Object
Returns the value of attribute label.
9 10 11 |
# File 'lib/matomo.rb', line 9 def label @label end |
#visits ⇒ Object
Returns the value of attribute visits.
9 10 11 |
# File 'lib/matomo.rb', line 9 def visits @visits end |
Class Method Details
.top ⇒ Object
23 |
# File 'lib/matomo.rb', line 23 def self.top() where end |
.where(**args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/matomo.rb', line 25 def self.where(**args) params = { method: "Referrers.getAll" }.merge( Matomo.date_range_params(args[:start_date], args[:end_date]) ) if args[:path] params[:segment] = "pageUrl==#{Matomo.tracked_site_url}#{args[:path]}" end resp = Matomo.get(params) return [] if resp.response.code != "200" resp.map{ |x| new(x) } end |
Instance Method Details
#actions_per_visit ⇒ Object
17 18 19 20 21 |
# File 'lib/matomo.rb', line 17 def actions_per_visit return 0 unless @actions and @visits return 0 if @visits == 0 (@actions/@visits.to_f).round(1) end |