When I first started using Google Analytics for a personal project it was difficult to tell how many actual page views my app was receiving because while developing new features in my Angular app I was sending “page views” to Google Analytics.
This is a quick guide to stop Google Analytics from sending data while you are are in the process of developing your application.
I am using the 4th version of Google Analytics (GA4) and Angular 9.
Block your Development IP Address in Google Analytics
Google Analytics offers the ability to block the collection of Analytics data from a specific IP address (or a group of IP addresses).
If you simply add the IP address where you do most of your development to this “block” list, then you will no longer be logging “page views” while you navigate your app during development.
To set this up, navigate to the Admin section of your web property in Google Analytics. Then select “Data Streams”, you will see the list of data streams.
Select the data stream that you want to add IP blocking for. Then find the “Additional Settings” tab and click “Tagging Settings”, this is the area where we can define an internal traffic IP.
Now that you are inside of the “More Tagging Settings” area, click “Define internal traffic”. At this point we will need to create a rule to add our list of Internal traffic rules.
Create a New Traffic Rule
Define a rule name, set the “traffic_type” value to internal. Then on the IP address match value put your IP address. Not sure what your current IP Address is? Use this free IP Address Check Tool.
Here is what my rule looks like in Google Analytics (I used 192.168.0.1 for demonstration, set your IP address instead.)
Confirm That Your IP Address is Blocked
To check to make sure that your IP address is successfully blocked open your the Realtime tab in your Google Analytics.
Then navigate to your app via localhost (or to the production URL from your desired IP address).
If your internal traffic rule is setup properly you will not see any Realtime users. If you are having issues at this point I recommend attempting to setup the rule again or waiting a few minutes for the rule to propagate across Google’s system.
I hoped this helped you, thanks for reading!