module Matomo::ViewHelpers
Public Instance Methods
matomo_tracking_embed(opts = {})
click to toggle source
# File lib/matomo/view_helpers.rb, line 3 def matomo_tracking_embed(opts = {}) content_tag(:div, id: "anon-stats") do content_tag(:noscript) do tag(:img, src: matomo_tracking_url(opts), style: "border:0", alt: "") end + javascript_tag do "document.getElementById('anon-stats').innerHTML = '<img src=\"#{matomo_tracking_url(opts)}&urlref=' + encodeURIComponent(document.referrer) + '\" style=\"border:0\" alt=\"\" />';".html_safe end end end
matomo_tracking_url(opts = {})
click to toggle source
# File lib/matomo/view_helpers.rb, line 14 def matomo_tracking_url(opts = {}) "#{Matomo.base_url}/js/?" + { idsite: Matomo.site_id, rec: 1, action_name: action_name_or_default(opts[:action_name]), url: request.original_url }.compact.to_param end
Private Instance Methods
action_name_or_default(name)
click to toggle source
# File lib/matomo/view_helpers.rb, line 25 def action_name_or_default(name) return name unless name.nil? return page_title if defined?(page_title) return nil end