Module: Utopia::Tags::GoogleAnalytics

Defined in:
lib/utopia/tags/google-analytics.rb,
lib/utopia/tags/google-analytics/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.call(transaction, state) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/utopia/tags/google-analytics.rb', line 24

def self.call(transaction, state)
  id = state['id']
  
  html = "    <script>\n      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n        \n      ga('create', \#{Trenni::Strings.to_quoted_string(id)}, 'auto');\n      ga('send', 'pageview');\n    </script>\n  EOF\n  \n  transaction.cdata(html)\nend\n"