Search for the Article

Exclude local host traffic from Google Analytics

local host

“localhost” refers to the local device making a request. LocalHost is used as a kind of staging area for displaying pages and running scripts on your own computer without having to worry of live website.

If a developer or team of developer are using localhost to test and develop website pages then you will get traffic from localhost in your google analytics. It is because those pages too contain the Google analytics script on them. This kind of traffic you can be seen your referral sources. It will affect your not only the traffic but other metrics too like bounce rate, time on site and many other metrics.

This you can exclude the traffic by filtering this type of traffic in Google analytics.

Filter traffic that is coming through localhost or other locally hosted sites, some of the traffic sources listed below 

  • localhost:3000
  • localhost
  • localhost/education/

Step by step process to exclude localhost traffic from Google Analytics

  1. Google Analytics Admin > Filters
  2. New filter, Name it "Exclude Localhost" or whatever you want
  3. Filter type > Predefined > Exclude
  4. Select source & destination > Traffic to the hostname
  5. Select expression > that begins with > localhost
  6. Verify the filter - if you had any traffic to speak of, it will show up here.
  7. Save