Class: GoogleAnalyticsTools::AsyncTrackingQueue
- Inherits:
-
Object
- Object
- GoogleAnalyticsTools::AsyncTrackingQueue
- Defined in:
- lib/google_analytics_tools/tracking/async_tracking_queue.rb
Constant Summary collapse
- SCRIPT =
"<script type=\"text/javascript\">\n(function() {\nvar ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\nga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\nvar s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n})();\n</script>\n"
Class Method Summary collapse
Instance Method Summary collapse
- #<<(event) ⇒ Object
-
#initialize ⇒ AsyncTrackingQueue
constructor
A new instance of AsyncTrackingQueue.
- #push(event, tracker_id = nil) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ AsyncTrackingQueue
Returns a new instance of AsyncTrackingQueue.
19 20 21 |
# File 'lib/google_analytics_tools/tracking/async_tracking_queue.rb', line 19 def initialize @events = [] end |
Class Method Details
.script ⇒ Object
15 16 17 |
# File 'lib/google_analytics_tools/tracking/async_tracking_queue.rb', line 15 def self.script SCRIPT end |
Instance Method Details
#<<(event) ⇒ Object
23 24 25 |
# File 'lib/google_analytics_tools/tracking/async_tracking_queue.rb', line 23 def <<(event) push(event) end |
#push(event, tracker_id = nil) ⇒ Object
27 28 29 |
# File 'lib/google_analytics_tools/tracking/async_tracking_queue.rb', line 27 def push(event, tracker_id = nil) @events << renderer_for_event(event, tracker_id) end |
#to_s ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/google_analytics_tools/tracking/async_tracking_queue.rb', line 31 def to_s "<script type=\"text/javascript\">\nvar _gaq = _gaq || [];\n\#{@events.map { |event| event.to_s }.join(\"\\n\")}\n</script>\n" end |