Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/backupify/analytical into…
Browse files Browse the repository at this point in the history
… backupify-master
  • Loading branch information
jkrall committed Mar 15, 2011
2 parents 7678f06 + 7993e13 commit b81baa5
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 1 deletion.
47 changes: 47 additions & 0 deletions lib/analytical/modules/click_tale.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
module Analytical
module Modules
class ClickTale
include Analytical::Modules::Base

def initialize(options={})
super
@tracking_command_location = [:body_prepend, :body_append]
end

def init_javascript(location)
init_location(location) do
case location.to_sym
when :body_prepend
js = <<-HTML
<!-- Analytical Init: ClickTale Top part -->
<script type="text/javascript">
var WRInitTime=(new Date()).getTime();
</script>
<!-- ClickTale end of Top part -->
HTML
js
when :body_append
js = <<-HTML
<!-- Analytical Init: ClickTale Bottom part -->
<div id="ClickTaleDiv" style="display: none;"></div>
<script type='text/javascript'>
document.write(unescape("%3Cscript%20src='"+
(document.location.protocol=='https:'?
'https://clicktale.pantherssl.com/':
'http://s.clicktale.net/')+
"WRb6.js'%20type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var ClickTaleSSL=1;
if(typeof ClickTale=='function') ClickTale(#{@options[:project_id]},#{@options[:site_traffic]},"www");
</script>
<!-- ClickTale end of Bottom part -->
HTML
js
end
end
end

end
end
end
2 changes: 1 addition & 1 deletion lib/analytical/modules/google.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def init_javascript(location)
<!-- Analytical Init: Google -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '#{options[:key]}'], ['_trackPageview']);
_gaq.push(['_setAccount', '#{options[:key]}'], ['_setDomainName', '#{options[:domain]}'], ['_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';
Expand Down
62 changes: 62 additions & 0 deletions lib/analytical/modules/google_optimizer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module Analytical
module Modules
class GoogleOptimizer
include Analytical::Modules::Base

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

def init_javascript(location)
init_location(location) do
js = <<-HTML
<!-- Analytical Init: Google Website Optimizer Control Script -->
<script>
function utmx_section(){}function utmx(){}
(function(){var k='#{options[:key]}',d=document,l=d.location,c=d.cookie;function f(n){
if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.indexOf(';',i);return c.substring(i+n.
length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript src="'+
'http'+(l.protocol=='https:'?'s://ssl':'://www')+'.google-analytics.com'
+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='
+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
'" type="text/javascript" charset="utf-8"></sc'+'ript>')})();
</script>
<!-- End of Google Website Optimizer Control Script -->
<!-- Analytical Init: Google Website Optimizer Tracking Script -->
<script type="text/javascript">
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {
var gwoTracker=_gat._getTracker("#{options[:account]}");
gwoTracker._trackPageview("/#{options[:key]}/test");
}catch(err){}</script>
<!-- End of Google Website Optimizer Tracking Script -->
HTML
js
end
end

def conversion(*args)
js = <<-HTML
<!-- Analytical Init: Google Website Optimizer Conversion Script -->
<script type="text/javascript">
if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
(document.location.protocol=='https:'?'s://ssl':'://www')+
'.google-analytics.com/ga.js"></sc'+'ript>')</script>
<script type="text/javascript">
try {
var gwoTracker=_gat._getTracker("#{options[:account]}");
gwoTracker._trackPageview("/#{options[:key]}/goal");
}catch(err){}</script>
<!-- End of Google Website Optimizer Conversion Script -->
HTML
js
end

end
end
end
30 changes: 30 additions & 0 deletions lib/analytical/modules/loopfuse.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Analytical
module Modules
class Loopfuse
include Analytical::Modules::Base

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

def init_javascript(location)
init_location(location) do
js = <<-HTML
<!-- Analytical Init: LOOPFUSE TRACKING -->
<script type="text/javascript">
var LFHost = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + LFHost + "lfov.net/webrecorder/js/listen.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
_lf_cid = "#{options[:cid]}";
_lf_remora();
</script>
<!-- END: LOOPFUSE TRACKING -->
HTML
js
end
end
end
end
end
34 changes: 34 additions & 0 deletions lib/analytical/modules/performancing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Analytical
module Modules
class Performancing
include Analytical::Modules::Base

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

def init_javascript(location)
init_location(location) do
js = <<-HTML
<!-- Analytical Init: Performancing Metrics -->
<script type="text/javascript">
var clicky = { log: function(){ return; }, goal: function(){ return; }};
var clicky_site_id = #{options[:site_id]};
(function() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = ( document.location.protocol == 'https:' ? 'https://pmetrics.performancing.com' : 'http://pmetrics.performancing.com' ) + '/js';
( document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0] ).appendChild( s );
})();
</script>
<!-- End Performancing Metrics -->
HTML
js
end
end

end
end
end

0 comments on commit b81baa5

Please sign in to comment.