Skip to content

Commit

Permalink
Added Mouseflow module
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrall committed Sep 22, 2013
1 parent 14359c0 commit 7ecf8ad
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Service implementations include:
* MixPanel[http://www.mixpanel.com]
* Gauges[http://get.gaug.es]
* Segment.io[http://segment.io]
* Mouseflow[http://mouseflow.com]

== Usage

Expand Down
40 changes: 40 additions & 0 deletions lib/analytical/modules/mouseflow.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module Analytical
module Modules
class Mouseflow
include Analytical::Modules::Base

def initialize(options={})
super
check_js_url
@tracking_command_location = :body_append
end

def init_javascript(location)
init_location(location) do
js = <<-HTML
<!-- Analytical Init: Mouseflow -->
<script type="text/javascript">
var _mfq = _mfq || [];
(function() {
var mf = document.createElement("script"); mf.type = "text/javascript"; mf.async = true;
mf.src = "#{options[:js_url]}";
document.getElementsByTagName("head")[0].appendChild(mf);
})();
</script>
HTML
js
end
end

private

def check_js_url
if options[:js_url].nil?
raise "You didn't provide a js_url for mouseflow. " +
"Add one to your analytical.yml file so Mouseflow will work."
end
end

end
end
end

0 comments on commit 7ecf8ad

Please sign in to comment.