How to use Panelbear with Ruby on Rails

Once you have added your website to Panelbear, all that is left to do is integrate our analytics snippet.

It's a small piece of code that runs on your website, and it collects the metrics necessary to show you the insights in the dashboard. For more information on what it collects check out What do we collect?.

Install script

Installing the analytics script on your Ruby on Rails project is super simple. All you need to do is:

  1. Go to the settings page for the site.
  2. Copy the snippet shown in the Analytics.js snippet section.
  3. Paste the snippet on your website's base HTML template, preferably at the bottom of the <head> section.

In case you are also handling client side routing changes via React, you can enable SPA mode easily (don't forget to use your own Site ID):

<!-- Panelbear Analytics - We respect your privacy -->
<script async src="https://cdn.panelbear.com/analytics.js?site=YOUR_SITE_ID"></script>
<script>
    window.panelbear = window.panelbear || function() { (window.panelbear.q = window.panelbear.q || []).push(arguments); };
    panelbear('config', {
        site: 'YOUR_SITE_ID',
        spaMode: 'history',
        debug: false,
    });
</script>

Check your installation

After you have added our analytics script to the HTML of your website, you should be able to see pageviews show up in the dashboard within a minute of the visitors coming into your website.

Testing your website locally? Check out our local development guide for some tips and tricks.

Mission complete!

Congratulations on completing the integration with Panelbear. That was easy, wasn't it? You now benefit of blazingly fast analytics, without compromising the privacy of your visitors.

Now all that's left to do is to let Panelbear do it's magic over time and you can view the insights in the dashboard.