lib/nanoc/toolbox/helpers/google_analytics.rb
def ga_tracking_snippet(ga_tracking_code=nil)
      ga_tracking_code ||= @config[:ga_tracking_code] || "UA-xxxxxx-x"
      js = <<-EOS
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '#{ga_tracking_code}']);
        _gaq.push(['_trackPageview']);

        (function() {
          var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
          ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
          var s  = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
      EOS
      content_tag('script', js, { :type => 'text/javascript' })
    end
# Return the javascript code snipet to use in your layout or views
#
# @param [String] ga_tracking_code the Google Analytics Tracking Code
# @return [String] the script tag to place in your layout
Return the javascript code snipet to use in your layout or views
Return the javascript code snipet to use in your layout or views
def ga_tracking_snippet(ga_tracking_code=nil)
      ga_tracking_code ||= @config[:ga_tracking_code] || "UA-xxxxxx-x"
      js = <<-EOS
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '#{ga_tracking_code}']);
        _gaq.push(['_trackPageview']);
        (function() {
          var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
          ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
          var s  = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
      EOS
      content_tag('script', js, { :type => 'text/javascript' })
    end
def ga_tracking_snippet ( ga_tracking_code = nil ) ga_tracking_code ||= @config [ :ga_tracking_code ] || "UA-xxxxxx-x" js = <<-EOS 
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', ' #{ ga_tracking_code } ']);
        _gaq.push(['_trackPageview']);

        (function() {
          var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
          ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
          var s  = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();
       EOS content_tag ( 'script' , js , { :type => 'text/javascript' } ) end
Return the javascript code snipet to use in your layout or views
Return the javascript code snipet to use in your layout or views
the script tag to place in your layout
the script tag to place in your layout
String
ga_tracking_code
ga_tracking_code the Google Analytics Tracking Code
ga_tracking_code the Google Analytics Tracking Code