问题
I recently launched a website and I'm using google analytics to track traffic and trends. Unfortunately I like to check on the site a lot myself along with my business partner, and our data is affecting our google analytics! Is there a simple way to make it such that certain user activity won't get tracked by google analytics?
I'm thinking of maybe attaching another domain name (or subdomain) to my site that I can access my website through. If I do that, will that still get logged?
Is there some other sort of trickery I can use so that my data will be uncorrupted by my own usage?
Thanks!
回答1:
Every page that is to be tracked needs to have a small script from google in it, in order for google to receive tracking data.
If you don't run that script, google gets no data.
If your web pages are produced dynamically by PHP, django, or similar, then you could decide when to print google's script into these dynamic pages dynamically, and not do it when requests are made from IP addresses whitelisted by the company.
But if your pages are static, that is more of a problem.
For static sites, you can create a special page that contains a link to any "most used" pages by insiders, and then check document.referer to decide whether to run that script.
But that won't work for rich static sites where the internal user starts clicking around. For those, I would recommend running google's script with a setTimeout() delay, and calling clearTimeout() if the incoming user confirms they are an internal user. This might check a "secret handshake" of the form "click the company logo in the first 5 sec and you dont get tracked" to call the clearTimeout().
Alternatively, within the analytics.google.com data portal you can filter data on "network domain" of visitors. If you have your own corporate name showing as the network domain, instead of "verizon" or the isp name, then you are set for writing an exclusion filter. Otherwise you could use city or state, though that would filter out more.
来源:https://stackoverflow.com/questions/17539053/prevent-my-data-from-affecting-google-analytics