when I access localhost, those sessions are included in hotjar statistics.
Is there a way to prevent this?
Here's a simple way to only use hotjar in production (thanks to @SebastianPalma for this solution):
<% if !current_page?(controller: 'home', action: 'dashboard') %> <% if Rails.env.production? %> <script> (function(h,o,t,j,a,r){ h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)}; h._hjSettings={hjid:2019490,hjsv:6}; a=o.getElementsByTagName('head')[0]; r=o.createElement('script');r.async=1; r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv; a.appendChild(r); })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); </script> <% end %> <% end %>
If you want to exclude hotjar from certain pages even in production (e.g. your admin dashboard), wrap the above code in this:
<% if !current_page?(controller: 'home', action: 'dashboard') %> <% end %>
Copyright © 2021 Jogjafile Inc.
Here's a simple way to only use hotjar in production (thanks to @SebastianPalma for this solution):
If you want to exclude hotjar from certain pages even in production (e.g. your admin dashboard), wrap the above code in this: