Class: Matomo::Referrer

Inherits:
Object
  • Object
show all
Defined in:
lib/matomo.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#labelObject

Returns the value of attribute label.



9
10
11
# File 'lib/matomo.rb', line 9

def label
  @label
end

#visitsObject

Returns the value of attribute visits.



9
10
11
# File 'lib/matomo.rb', line 9

def visits
  @visits
end

Class Method Details

.topObject



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_visitObject



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