Class: Orange::Middleware::Analytics
- Inherits:
-
Base
- Object
- Base
- Orange::Middleware::Analytics
- Defined in:
- lib/orange-more/analytics/middleware/analytics.rb
Instance Method Summary collapse
-
#packet_call(packet) ⇒ Object
Passes packet then parses the return.
Instance Method Details
#packet_call(packet) ⇒ Object
Passes packet then parses the return
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/orange-more/analytics/middleware/analytics.rb', line 7 def packet_call(packet) pass packet ga_key = orange.['google_analytics_key'] || false if packet['route.context'] == :live && ga_key ga = "<script type=\"text/javascript\"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '"+ga_key+"']); _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); })(); </script>" packet[:content] = packet[:content].sub(/.*<\/head>$/, ga + '</head>') end packet.finish end |