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.4.2.x8 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x7 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x6 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x5 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x4 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x3 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x2 lib/awestruct/extensions/google_analytics.rb
awestruct-0.4.2.x1 lib/awestruct/extensions/google_analytics.rb
awestructx-0.4.1.x1 lib/awestruct/extensions/google_analytics.rb
awestructx-0.4.1 lib/awestruct/extensions/google_analytics.rb
awestructx-0.4.0 lib/awestruct/extensions/google_analytics.rb
awestruct-0.2.18 lib/awestruct/extensions/google_analytics.rb
awestruct-0.2.17 lib/awestruct/extensions/google_analytics.rb
awestruct-0.2.15 lib/awestruct/extensions/google_analytics.rb
awestruct-0.2.14 lib/awestruct/extensions/google_analytics.rb
awestruct-0.2.13 lib/awestruct/extensions/google_analytics.rb
awestruct-0.2.12 lib/awestruct/extensions/google_analytics.rb