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.3.174.51542603 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.3.115.227021242 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.3.73.75172665 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.3.2.153416031 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.3.67.110847540 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.3.1.23895778 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.2.36.82613853 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.2.7.128454143 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.1.26.236500544 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.1 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.539.93842523 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.529.114081979 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.518.30999728 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.515.34928522 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.498.46559598 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.480.261594408 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.444.171626367 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.406.131718077 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.356.19698103 app/helpers/rails_connector/tracking_helper.rb
infopark_rails_connector-6.8.0.348.160665197 app/helpers/rails_connector/tracking_helper.rb