Is there a way to stop Google Analytics counting development work as hits? Ask Question

Is there a way to stop Google Analytics counting development work as hits? Ask Question

I have added the JavaScript that I need to the bottom of my pages so that I can make use of Google Analytics. Only problem is that I am sure that it is counting all my development work as hits. Seeing as I probably see some of those pages a hundred times a day it will really skew my readings. Is there a way to turn it off from a particular IP address or is this something that should be built into my build process so it only gets added when I build for deployment?

ベストアンサー1

私は JavaScript を使用するシンプルなアプローチが好きです。どこでも動作します。

<script type="text/javascript">
if (document.location.hostname.search("myproductiondomainname.com") !== -1) {

//google analytics code goes here

}
</script>

おすすめ記事