Merge pull request #32 from monfresh/google-analytics

Update Google Analytics code and use env vars
This commit is contained in:
Erik Michaels-Ober 2014-04-21 06:53:07 +02:00
commit 7b7281dc45
2 changed files with 22 additions and 3 deletions

View File

@ -66,7 +66,19 @@ A successful deployment to Heroku requires a few setup steps:
`heroku run bundle exec rake db:seed`
6. Keep in mind that the Heroku free Postgres plan only allows up to 10,000 rows, so if your city has more than 10,000 fire hydrants (or other thing to be adopted), you will need to upgrade to the $9/month plan.
Keep in mind that the Heroku free Postgres plan only allows up to 10,000 rows,
so if your city has more than 10,000 fire hydrants (or other thing to be
adopted), you will need to upgrade to the $9/month plan.
### Google Analytics
If you have a Google Analytics account you want to use to track visits to your
deployment of this app, just set your ID and your domain name as environment
variables:
heroku config:set GOOGLE_ANALYTICS_ID=your_id
heroku config:set GOOGLE_ANALYTICS_DOMAIN=your_domain_name
An example ID is `UA-12345678-9`, and an example domain is `adoptahydrant.org`.
## Contributing
In the spirit of [free software][free-sw], **everyone** is encouraged to help

View File

@ -12,8 +12,15 @@
= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"
= javascript_include_tag "//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
= javascript_include_tag "application"
%script{:type => "text/javascript"}
var _gaq=_gaq||[];_gaq.push(["_setAccount","UA-20825280-2"]),_gaq.push(["_setDomainName",".adoptahydrant.org"]),_gaq.push(["_trackPageview"]),function(){var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=("https:"==document.location.protocol?"https://ssl":"http://www")+".google-analytics.com/ga.js";var b=document.getElementsByTagName("script")[0];b.parentNode.insertBefore(a,b)}();
- if Rails.env.production? && ENV['GOOGLE_ANALYTICS_ID'].present?
%script{:type => "text/javascript"}
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '#{ENV['GOOGLE_ANALYTICS_ID']}', '#{ENV['GOOGLE_ANALYTICS_DOMAIN']}');
ga('send', 'pageview');
= stylesheet_link_tag "application"
%body
= yield