Permalink
Browse files

modified to set the domain name for Google Analytics plugin

  • Loading branch information...
1 parent e372b45 commit 65adf5192684d199973e8d3ea40e2a4e7ecc301e @nkmrshn nkmrshn committed Nov 20, 2010
Showing with 10 additions and 1 deletion.
  1. +6 −1 lib/lokka/google_analytics.rb
  2. +4 −0 views/index.haml
@@ -7,15 +7,20 @@ def self.registered(app)
app.put '/admin/plugins/google_analytics' do
Option.tracker = params['tracker']
+ Option.tracker_dn = params['tracker_dn']
flash[:notice] = 'Updated.'
redirect '/admin/plugins/google_analytics'
end
app.before do
tracker = Option.tracker
if !tracker.blank? and ENV['RACK_ENV'] == 'production' and !logged_in?
+ dn = Option.tracker_dn
+ tracker_script = "<script type=\"text/javascript\">var _gaq=_gaq||[];_gaq.push(['_setAccount','#{tracker}']);"
+ tracker_script += "_gaq.push(['_setDomainName', '.#{dn}']);" unless dn.blank?
+ tracker_script += "_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>"
content_for :header do
- "<script type=\"text/javascript\">var _gaq=_gaq||[];_gaq.push(['_setAccount','#{tracker}']);_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>"
+ tracker_script
end
end
end
View
@@ -8,4 +8,8 @@
%br
%input{:type => 'text', :id => 'post_title', :name => 'tracker', :value => Option.tracker}
.field
+ %label{:for => 'dn_title'} Domain Name (Optional)
+ %br
+ %input{:type => 'text', :id => 'dn_title', :name => 'tracker_dn', :value => Option.tracker_dn}
+ .field
%input{:type => 'submit', :value => t.edit}

0 comments on commit 65adf51

Please sign in to comment.