Question
How can I prevent Analytics.js from sending events to Segment for users coming from specific IP addresses?
Product
Segment
Environment
Segment Console
Answer
Segment does not provide a built-in feature to block events from specific IP addresses. However, if you have access to the code where Analytics.js is implemented, you can use a Source Middleware function. Middlewares allow you to run custom JavaScript on every event before it is sent to Segment. By adding logic to check the user’s IP address, you can prevent events from being sent if they match a blocked list.
Additional Information
Source and Destination Middlewares are available on Analytics.js snippet version 4.12.0 and later.