Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Using Google Analytics

  • Loading branch information...
commit 079a5585bbbccf46aad54b75e775be2f2e91a318 1 parent be20979
@swaroopch authored
Showing with 15 additions and 12 deletions.
  1. +13 −12 app/views/layouts/application.html.erb
  2. +2 −0  config/app_config.yml
View
25 app/views/layouts/application.html.erb
@@ -96,20 +96,21 @@
%>
<!-- end profiling code -->
+ <!-- Google Analytics -->
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '<%= configatron.google_analytics_id %>']);
+ _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);
+ })();
- <!-- asynchronous google analytics: mathiasbynens.be/notes/async-analytics-snippet
- change the UA-XXXXX-X to be your site's ID -->
- <script>
- var _gaq = [['_setAccount', '<%= google_analytics_id || 'UA-XXXXX-X' %>'], ['_trackPageview']];
- (function(d, t) {
- var g = d.createElement(t),
- s = d.getElementsByTagName(t)[0];
- g.async = true;
- g.src = ('https:' == location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- s.parentNode.insertBefore(g, s);
- })(document, 'script');
</script>
-
+
<script>
<%= yield(:js) %>
</script>
View
2  config/app_config.yml
@@ -1,9 +1,11 @@
common:
store_timeout: 5 # seconds
+ google_analytics_id: 'UA-12345678-9' # NOTE Dummy ID
development:
test:
production:
+ google_analytics_id: 'UA-20478102-1' # NOTE You'll have to change this for your own domain
Please sign in to comment.
Something went wrong with that request. Please try again.