Sha256: 4f8cc2705d192e6de694090f17c2e990debe92eae2276bb48ce03399d3c66a01

Contents?: true

Size: 1.58 KB

Versions: 37

Compression:

Stored size: 1.58 KB

Contents

module Awestruct
  module Extensions
    module GoogleAnalytics

      def google_analytics()
        html = ''
        html += %Q(<script type="text/javascript">\n)
        html += %Q(var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");\n)
        html += %Q(document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));\n)
        html += %Q(</script>\n)
        html += %Q(<script type="text/javascript">\n)
        html += %Q(try {\n)
        html += %Q(var pageTracker = _gat._getTracker("#{site.google_analytics}");\n)
        html += %Q(pageTracker._trackPageview();\n)
        html += %Q(} catch(err) {}</script>\n)
        html
      end

      def google_analytics_async()
        html = ''
        html += %Q(<script type="text/javascript">\n)
        html += %Q(var _gaq = _gaq || [];\n)
        html += %Q(_gaq.push(['_setAccount','#{site.google_analytics}']);\n)
        if site.google_analytics_anonymize
          html += %Q(_gaq.push(['_gat._anonymizeIp']);\n)
        end
        html += %Q(_gaq.push(['_trackPageview']);\n)
        html += %Q[(function() {\n]
        html += %Q( var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n)
        html += %Q( ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n)
        html += %Q( var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n)
        html += %Q[})();\n</script>\n]
        html
      end

    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
awestruct-0.5.4.rc3 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.4.rc2 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.4.rc lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.4.beta1 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.3 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.2.1 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.2 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.1 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.1a lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.0 lib/awestruct/extensions/google_analytics.rb
awestruct-0.5.0.cr lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.8 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.7 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.6 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.5 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.4 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.3 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x10 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x9 lib/awestruct/extensions/google_analytics.rb