Module: RailsConnector::TrackingHelper

Included in:
LayoutHelper
Defined in:
app/helpers/rails_connector/tracking_helper.rb

Overview

This module contains helpers for Google Analytics and Infopark Tracking.

Instance Method Summary collapse

Instance Method Details

#google_analyticsObject

This helper renders the Google Analytics snippet using the domain code for the current domain as configured via Configuration::GoogleAnalytics.domain_code. The helper is automatically run when using the rails_connector_after_content_tags, if the feature :google_analytics is enabled.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/rails_connector/tracking_helper.rb', line 12

def google_analytics
  if domain_code = Configuration::GoogleAnalytics.domain_code(request.host)
    raw %Q{
      <script type="text/javascript" src='#{ga_prefix}google-analytics.com/ga.js'></script>
      <script type="text/javascript">
        try {
          var pageTracker = _gat._getTracker("#{domain_code}");
          pageTracker._setAllowAnchor(true);
          pageTracker._addIgnoredOrganic("#{request.host}");
          pageTracker._trackPageview();
        } catch(err) {}
      </script>
    }
  end
end