Add support for Piwik analytics
authorTom Hughes <tom@compton.nu>
Fri, 16 Sep 2011 23:11:53 +0000 (00:11 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 16 Sep 2011 23:11:53 +0000 (00:11 +0100)
app/views/layouts/_piwik.html.erb [new file with mode: 0644]
app/views/layouts/site.html.erb
config/example.application.yml

diff --git a/app/views/layouts/_piwik.html.erb b/app/views/layouts/_piwik.html.erb
new file mode 100644 (file)
index 0000000..59017e0
--- /dev/null
@@ -0,0 +1,12 @@
+<!-- Piwik -->
+<script type="text/javascript">
+var pkBaseURL = (("https:" == document.location.protocol) ? "https://<%= PIWIK_LOCATION %>/" : "http://<%= PIWIK_LOCATION %>/");
+document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
+</script><script type="text/javascript">
+try {
+var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", <%= PIWIK_SITE %>);
+piwikTracker.trackPageView();
+piwikTracker.enableLinkTracking();
+} catch( err ) {}
+</script><noscript><p><img src="http://<%= PIWIK_LOCATION %>/piwik.php?idsite=<%= PIWIK_SITE %>" style="border:0" alt="" /></p></noscript>
+<!-- End Piwik Tracking Code -->
index 9cb6d3df081b9a722eded277ca906b6eb3937c85..9da2edf47a242a2368ccb954f6209e871a5d0cc0 100644 (file)
         </div>
       </center>
     </div>
+    <% if defined?(PIWIK_LOCATION) and defined?(PIWIK_SITE) -%>
+    <%= render :partial => "layouts/piwik" %>
+    <% end -%>
   </body>
 </html>
index abcd1ce41d8b8757f68f4813ac2d53885b967e53..f4a369487441054529f6f6a03924b87bc14f5974 100644 (file)
@@ -73,6 +73,9 @@ standard_settings: &standard_settings
   require_terms_seen: false
   # Whether to require users to agree to the CTs before editing
   require_terms_agreed: false
+  # Piwik details
+  #piwik_location: "piwik.openstreetmap.org"
+  #piwik_site: 1
 
 development:
   <<: *standard_settings