class Matomo::Referrer

Attributes

label[RW]
visits[RW]

Public Class Methods

new(params = {}) click to toggle source
# File lib/matomo.rb, line 11
def initialize(params = {})
  @label = params["label"]
  @visits = params["nb_visits"] || 0
  @actions = params["nb_actions"] || 0
end
top() click to toggle source
# File lib/matomo.rb, line 23
def self.top() where end
where(**args) click to toggle source
# 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

Public Instance Methods

actions_per_visit() click to toggle source
# 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