Question about Google Analytics Tracking (w/ Rails)

前端 未结 5 1514
深忆病人
深忆病人 2021-02-10 21:17

I\'ve got google analytics setup on a rails project, and I\'ve got \"A single domain (default)\" selected for the tracking options.

I\'ve copied and pasted the js code i

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-10 22:09

    Yes, it does track local visits as well. You should probably use ruby conditional statement to exclude it for the local conneciton. For example, at the bottom of the layout file

    <% if !request.local? %>
    Your source codes for Google Analytics
    <% end %>
    

    This way, Google Analytics will not be printed if connection is made from local.

提交回复
热议问题