Module: Matomo::ViewHelpers

Defined in:
lib/matomo/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#matomo_tracking_embedObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/matomo/view_helpers.rb', line 12

def matomo_tracking_embed
  (:div, id: "anon-stats") do
    (:noscript) do
      (:img, src: matomo_tracking_url, style: "border:0", alt: "")
    end
    javascript_tag do
      "document.getElementById('anon-stats').innerHTML = '<img src=\"#{matomo_tracking_url}\"?urlref=' + encodeURIComponent(document.referrer) + 'style=\"border:0\" alt=\"\" />';".html_safe
    end
  end
end

#matomo_tracking_urlObject



3
4
5
6
7
8
9
10
# File 'lib/matomo/view_helpers.rb', line 3

def matomo_tracking_url
  "https://anon-stats.eff.org/js/?" + {
    idsite: Matomo.site_id,
    rec: 1,
    action_name: page_title,
    url: request.original_url
  }.to_param
end