TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How can I trust Google Analytics?

32 点作者 goferito将近 10 年前
I&#x27;ve made a small proof of concept with Google Analytics. I was checking that running the frontend code coming from my localhost I could already receive the events on my Google Analytics (GA) account. So GA is just not running any kind of validation on where the events are coming from (domain check or something). Then, since the tracking ID remains public, it&#x27;s possible to just send any kind of event using someone else&#x27;s tracking ID, therefore messing with their insights in their GA dashboard. I have published the code on github.com&#x2F;goferito&#x2F;gapoc in case someone wants to take a look, even though it&#x27;s pretty simple.<p>So the question is, how can I know someone is not sending events (pageview events or whatever) using my tracking ID? Is there any way in GA to filter those, before or after GA stores them?

17 条评论

gk1将近 10 年前
I do marketing ops consulting and see this stuff all the time. First, let&#x27;s get two things out of the way:<p>1. Yes, Google Analytics can be quite useless if you keep default settings with no configuration.<p>2. That doesn&#x27;t mean you should jump straight to a self-hosted solution, or a paid solution, or throw up your hands and say &quot;it&#x27;ll never be accurate.&quot;<p>For most use cases, GA is more than good enough to measure effectiveness of online marketing efforts. Dismissing it outright in favor of a paid or self-hosted option just because you didn&#x27;t google &quot;how to prevent analytics hijacking&quot; is bad decision-making.<p>&#x2F;rant<p>Now on to the fix...<p>You can create a filter in your GA view settings to ignore tracking calls from any hostname other than your own. See here: <a href="https:&#x2F;&#x2F;support.google.com&#x2F;analytics&#x2F;answer&#x2F;1033162?hl=en" rel="nofollow">https:&#x2F;&#x2F;support.google.com&#x2F;analytics&#x2F;answer&#x2F;1033162?hl=en</a><p>PS - No client-side analytics will ever be 100% accurate, certainly not GA. But for the purposes of measuring marketing efforts and results, you can have greater tolerances. It&#x27;s a tool for marketing, not logging.
评论 #9858400 未加载
评论 #9859057 未加载
评论 #9858644 未加载
fiatjaf将近 10 年前
No, nothing is safe.<p>See <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7477736" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=7477736</a> or <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8869880" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8869880</a>
fasouto将近 10 年前
Nice experiment! Link for the lazy: <a href="https:&#x2F;&#x2F;github.com&#x2F;goferito&#x2F;gapoc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;goferito&#x2F;gapoc</a><p>I guess SEO people already know this, the question is: can you trust a SEO consultant?
评论 #9858109 未加载
评论 #9858492 未加载
评论 #9858415 未加载
评论 #9858304 未加载
gesman将近 10 年前
Taking advantage of GA deficiencies is widely used to inflate traffic figures during website sales negotiations.<p>GA is really not a product you want to trust your business with. Best approach is to consider self-hosted analytics solutions.<p>I built my own for my needs which also include combined features for security analytics to investigate malware attacks. GA is totally useless in this aspect.
评论 #9858382 未加载
jand将近 10 年前
There is a workaround - but it will reduce the amount of data points available to GA and put stress on your box: Use server-side tracking calls.<p>As said, this will remove all data points which are usually gathered by the GA-Javascript. Same thing is possible with Piwik.<p>You _could try_ to have custom JS that would gather those data-points like e.g. screen resolution.
sjs382将近 10 年前
You can&#x27;t know. GA spam is rampant, more so via referer spam than anything else.
评论 #9858114 未加载
评论 #9858470 未加载
fiatjaf将近 10 年前
The server cannot know if an event is coming from a browser or not, and anyone can make it look like coming from a browser while making it from another program, although you can&#x27;t do it inside a proper browser.
rotten将近 10 年前
Another caveat is that you have to wait 72 hours after the event before you can be reasonably sure the counts aren&#x27;t going to change any more. Sure, you get some results immediately, but for some reason, some take a long time to settle. I&#x27;m guessing it is a massive eventually consistent distributed database, and that GA hits are going to nearest or least busy nodes and it just takes a while for them all to sync up.
achairapart将近 10 年前
Experienced this a few times when somebody cloned my whole website, GA tracking code included.<p>Also, with the increasing spam coming from referrer and the new trend of adv blocking plugins (they block GA too), Google Analytics has become less reliable than ever.<p>However, you can setup open source analytics software on your own server, like [Piwik](<a href="http:&#x2F;&#x2F;piwik.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;piwik.org&#x2F;</a>).
an4rchy将近 10 年前
In addition to the other comments, you could always try to use another analytics product in parallel (from time to time randomly in the year) to quickly validate the accuracy of the results. This will serve as an indicator and also validate assumptions regarding the integrity of the analytics.
forgottenpass将近 10 年前
Update your javascript tracking code to include a nonce generated serverside. Send the nonce along with the rest of the report to the tracking server. Filter out reports with duplicate or missing nonces. Dunno if you can do it with GA, you might have to hack it into Piwik.
awavering将近 10 年前
You can add filters to exclude data before it gets recorded: <a href="http:&#x2F;&#x2F;viget.com&#x2F;advance&#x2F;removing-referral-spam-from-google-analytics" rel="nofollow">http:&#x2F;&#x2F;viget.com&#x2F;advance&#x2F;removing-referral-spam-from-google-...</a>
dabernathy89将近 10 年前
Analytics is useful but the information is certainly not to be trusted completely. Especially on the e-commerce side.<p>what blows my mind is that they aren&#x27;t doing more to fight the referral &#x2F; event tracking spam. it&#x27;s totally out of control.
tomclaus将近 10 年前
You can use a GA Filter based on your domain name. It solved my problem.
评论 #9858175 未加载
vgt将近 10 年前
If you are a Google Analytics Premium customer, your raw dataset is automatically available in BigQuery, so you can see down to every click and run your own SQL on it.
lmm将近 10 年前
I understand you&#x27;re supposed to whitelist in GA which pages are allowed to send a given tracking ID?
kelseydh将近 10 年前
We just ran into a problem with Google Analytics trying to track opening clicks by sending an event to GA. Turns out when you click a link to open it, the browser page would load before the event to GA could be sent.<p>Screwed up a huge amount of our click tracking data on GA.
评论 #9858197 未加载
评论 #9858632 未加载
评论 #9858142 未加载