Skip to content

Commit

Permalink
Per-site configuration of Google analytics, fixes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedlund committed Oct 1, 2013
1 parent aa86205 commit ea57031
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/views/site/_tracking.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- if Rails.env.production?
- if Rails.env.production? && @current_site.ga_account_id.present?
:javascript
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-28297028-1']); // FIXME
_gaq.push(['_setDomainName', 'activatehub.org']); // FIXME
_gaq.push(['_setAccount', #{@current_site.ga_account_id.to_json.html_safe}]);
_gaq.push(['_setDomainName', #{@current_site.domain.to_json.html_safe}]);
_gaq.push(['_trackPageview']);

(function() {
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20130930234907_add_ga_account_id_to_sites.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddGaAccountIdToSites < ActiveRecord::Migration
def change
add_column :sites, :ga_account_id, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130910114730) do
ActiveRecord::Schema.define(:version => 20130930234907) do

create_table "events", :force => true do |t|
t.string "title"
Expand Down Expand Up @@ -80,6 +80,7 @@
t.float "map_longitude"
t.integer "map_zoom"
t.string "locale"
t.string "ga_account_id"
end

create_table "sources", :force => true do |t|
Expand Down

0 comments on commit ea57031

Please sign in to comment.