Module: Rubaidh::GoogleAnalyticsViewHelper
- Defined in:
- lib/rubaidh/view_helpers.rb
Overview
Collection of methods similar to the ones in ActionView::Helpers::UrlHelper, with the addition of outbound link tracking. See the Google Analytics help at www.google.com/support/googleanalytics/bin/answer.py?answer=55527 for more information on outbound link tracking.
Instance Method Summary collapse
-
#link_to_tracked(name, track_path = "/", options = {}, html_options = {}) ⇒ Object
Creates a link tag of the given
name
using a URL created by the set ofoptions
, with outbound link tracking undertrack_path
in Google Analytics. -
#link_to_tracked_if(condition, name, track_path = "/", options = {}, html_options = {}, &block) ⇒ Object
Creates a link tag of the given
name
using a URL created by the set ofoptions
ifcondition
is true, with outbound link tracking undertrack_path
in Google Analytics. -
#link_to_tracked_unless(condition, name, track_path = "/", options = {}, html_options = {}, &block) ⇒ Object
Creates a link tag of the given
name
using a URL created by the set ofoptions
unlesscondition
is true, with outbound link tracking undertrack_path
in Google Analytics. -
#link_to_tracked_unless_current(name, track_path = "/", options = {}, html_options = {}, &block) ⇒ Object
Creates a link tag of the given
name
using a URL created by the set ofoptions
unless the current request URI is the same as the link’s, with outbound link tracking undertrack_path
in Google Analytics.
Instance Method Details
#link_to_tracked(name, track_path = "/", options = {}, html_options = {}) ⇒ Object
Creates a link tag of the given name
using a URL created by the set of options
, with outbound link tracking under track_path
in Google Analytics. The html_options
will accept a hash of attributes for the link tag.
10 11 12 13 14 |
# File 'lib/rubaidh/view_helpers.rb', line 10 def link_to_tracked(name, track_path = "/", = {}, = {}) raise AnalyticsError.new("You must set Rubaidh::GoogleAnalytics.defer_load = false to use outbound link tracking") if GoogleAnalytics.defer_load == true .merge!({:onclick => tracking_call(track_path)}) link_to name, , end |
#link_to_tracked_if(condition, name, track_path = "/", options = {}, html_options = {}, &block) ⇒ Object
Creates a link tag of the given name
using a URL created by the set of options
if condition
is true, with outbound link tracking under track_path
in Google Analytics. The html_options
will accept a hash of attributes for the link tag.
19 20 21 22 23 |
# File 'lib/rubaidh/view_helpers.rb', line 19 def link_to_tracked_if(condition, name, track_path = "/", = {}, = {}, &block) raise AnalyticsError.new("You must set Rubaidh::GoogleAnalytics.defer_load = false to use outbound link tracking") if GoogleAnalytics.defer_load == true .merge!({:onclick => tracking_call(track_path)}) link_to_unless !condition, name, , , &block end |
#link_to_tracked_unless(condition, name, track_path = "/", options = {}, html_options = {}, &block) ⇒ Object
Creates a link tag of the given name
using a URL created by the set of options
unless condition
is true, with outbound link tracking under track_path
in Google Analytics. The html_options
will accept a hash of attributes for the link tag.
28 29 30 31 32 |
# File 'lib/rubaidh/view_helpers.rb', line 28 def link_to_tracked_unless(condition, name, track_path = "/", = {}, = {}, &block) raise AnalyticsError.new("You must set Rubaidh::GoogleAnalytics.defer_load = false to use outbound link tracking") if GoogleAnalytics.defer_load == true .merge!({:onclick => tracking_call(track_path)}) link_to_unless condition, name, , , &block end |
#link_to_tracked_unless_current(name, track_path = "/", options = {}, html_options = {}, &block) ⇒ Object
Creates a link tag of the given name
using a URL created by the set of options
unless the current request URI is the same as the link’s, with outbound link tracking under track_path
in Google Analytics. If the request URI is the same as the link URI, only the name is returned, or the block is yielded, if one exists. The html_options
will accept a hash of attributes for the link tag.
39 40 41 42 43 |
# File 'lib/rubaidh/view_helpers.rb', line 39 def link_to_tracked_unless_current(name, track_path = "/", = {}, = {}, &block) raise AnalyticsError.new("You must set Rubaidh::GoogleAnalytics.defer_load = false to use outbound link tracking") if GoogleAnalytics.defer_load == true .merge!({:onclick =>tracking_call(track_path)}) link_to_unless current_page?(), name, , , &block end |