Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

modified to set the domain name for Google Analytics plugin

  • Loading branch information...
commit 65adf5192684d199973e8d3ea40e2a4e7ecc301e 1 parent e372b45
@nkmrshn nkmrshn authored
Showing with 10 additions and 1 deletion.
  1. +6 −1 lib/lokka/google_analytics.rb
  2. +4 −0 views/index.haml
View
7 lib/lokka/google_analytics.rb
@@ -7,6 +7,7 @@ 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
@@ -14,8 +15,12 @@ def self.registered(app)
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
4 views/index.haml
@@ -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}
Please sign in to comment.
Something went wrong with that request. Please try again.