Sha256: f850755292d2ab6853aad7ee3281d5f972fe2a682a6faa6081817a6f1e62d701
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'nanoc/toolbox/helpers/html_tag' module Nanoc::Toolbox::Helpers # NANOC Helper for the Google Analytics JS to add at the end of the layout. # # This module contains helper functions to generate the JS code snipet # used to track your site analytics by simply entering your tracking ID as # parameter or in the configuration file # # @see http://www.google.com/analytics/ # @author Anouar ADLANI <anouar@adlani.com> module GoogleAnalytics include Nanoc::Toolbox::Helpers::HtmlTag def ga_tracking_snippet(ga_tracking_code=nil) ga_tracking_code ||= @site.config[:ga_tracking_code] 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nanoc-toolbox-0.0.7 | lib/nanoc/toolbox/helpers/google_analytics.rb |
nanoc-toolbox-0.0.6 | lib/nanoc/toolbox/helpers/google_analytics.rb |