Class: UrchinTrackingModule

Inherits:
Object
  • Object
show all
Defined in:
lib/urchin_tracking_module.rb,
lib/urchin_tracking_module/version.rb

Defined Under Namespace

Modules: Slicable Classes: Defaults

Constant Summary collapse

TRACKING_PARAMETERS =
%i(utm_source utm_medium utm_term utm_content utm_campaign)
VERSION =
"1.0.6"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ UrchinTrackingModule

Returns a new instance of UrchinTrackingModule.



16
17
18
# File 'lib/urchin_tracking_module.rb', line 16

def initialize(url)
  @url = url
end

Class Method Details

.configure(&block) ⇒ Object



57
58
59
# File 'lib/urchin_tracking_module.rb', line 57

def self.configure(&block)
  Defaults.configure(&block)
end

.mediumObject



65
66
67
# File 'lib/urchin_tracking_module.rb', line 65

def self.medium
  Defaults.config[:utm_medium]
end

.sourceObject



61
62
63
# File 'lib/urchin_tracking_module.rb', line 61

def self.source
  Defaults.config[:utm_source]
end

Instance Method Details

#tracking(params = defaults) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/urchin_tracking_module.rb', line 20

def tracking(params=defaults)
  filtered_params(params).inject(@url) do |url,(name,value)|
    unless value.nil?
      url = add_param(url, "#{name}", value)
      url = add_param(url, "src", value) if name == :utm_source
    end
    url
  end
end