[英]How to disable hotjar on localhost rails?
當我訪問 localhost 時,這些會話包含在 hotjar 統計信息中。
有沒有辦法防止這種情況?
這是僅在生產中使用 hotjar 的簡單方法(感謝@SebastianPalma 提供此解決方案):
<% 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 %>
如果您想在生產中(例如您的管理儀表板)從某些頁面中排除 hotjar,請將上面的代碼包裝在此:
<% if !current_page?(controller: 'home', action: 'dashboard') %>
<% end %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.