Sha256: 6d735a1b7f8a45050361a6bbadcc8048d37d6b4c0926a7131699deedf653e81b

Contents?: true

Size: 1.14 KB

Versions: 22

Compression:

Stored size: 1.14 KB

Contents

module RailsConnector

  # This module contains helpers for Google Analytics and Infopark Tracking.
  # @api public
  module TrackingHelper

    # This helper renders the Google Analytics snippet using the domain code
    # for the current domain as configured via <tt>Configuration::GoogleAnalytics.domain_code</tt>.
    # The helper is automatically run when using the +rails_connector_after_content_tags+,
    # if the feature <tt>:google_analytics</tt> is enabled.
    # @api public
    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

    private

    def ga_prefix
      request.ssl? ? 'https://ssl.' : 'http://www.'
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
infopark_rails_connector-6.8.0.328.4a753fc app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.322.c003f11 app/helpers/rails_connector/tracking_helper.rb