forked from jkrall/analytical
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |