To reduce costs, I’m looking to implement an Opting Users Out of Tracking feature entirely on the client side, without using a server. I’m considering using internal IP addresses to differentiate and exclude internal employees from data collection. Are there any better approaches I should consider?
Hi jtw, Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
Yes, Mixpanel provides several methods to manage user tracking and data collection in a privacy-friendly way. 1. Opting Users Out of Tracking: You can use the opt_out_tracking()
method in Mixpanel's SDKs to opt users out of tracking. This state is controlled by a flag that is set as a browser cookie or localStorage. If you want to opt users out of tracking by default, you can configure the SDKs accordingly. Here is how you can do it in Javascript:LBKSmixpanel.opt_out_tracking(); mixpanel.init(YOUR TOKEN, {opt_out_tracking_by_default: true});LBKS
Source2. Disabling Geolocation: Mixpanel's Web and Mobile libraries use IP address to enrich events with geographic information like city, country, and region. You can disable this using the following configuration options in each of our SDKs:LBKSmixpanel.init("YOUR_TOKEN", {"ip": false})LBKS
Source3. Anonymizing Users: If you want to analyze aggregate user behavior without being able to drill down into any particular user, you can generate a hash of some unique ID of the user and use that hash as the user's ID when you call the .identify()
method in the SDKs. Source4. Data Views: If you have an active Enterprise plan with Mixpanel, you can use Data Views to manage data access for a group of users within a single Mixpanel project. For example, you can create a Data View for customer data by excluding data tracked by your internal users/employees. Source5. Blacklisting Default Properties: You can prevent the setting of default properties using the property_blacklist
config option. For example, to prevent default event properties from being sent, specify a list of properties to blacklist on library load:LBKSmixpanel.init("YOUR_TOKEN", { property_blacklist: ['$referrer', 'custom_property'] });LBKS
SourceRemember, while these methods can help you manage data collection and user tracking, it's important to ensure that your practices comply with relevant privacy laws and regulations.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.
Let me check the knowledge base for you again. One moment! 📚
To avoid tracking internal employees, you can use Mixpanel's opt_out_tracking()
method. This method allows you to opt users out of tracking. The state of this setting is controlled by a flag that is set as a browser cookie or localStorage. Here is how you can implement it in Javascript:LBKSmixpanel.opt_out_tracking();LBKS
If you want to opt users out of tracking by default, you can configure the SDKs accordingly:LBKSmixpanel.init(YOUR TOKEN, {opt_out_tracking_by_default: true});LBKS
You can call these methods when the user is identified as an internal employee. The identification can be done based on certain criteria like email domain, user role, etc. Please note that because this setting is stateful, it only exists on Mixpanel's Web/Mobile SDKs. If you're tracking from your servers, you will need to store this opt-out setting in a database and check it before sending any track calls.For more information, you can refer to the Mixpanel documentation on protecting user data.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.
Let me check the knowledge base for you again. One moment! 📚
There are several ways to identify internal employees in your application. Here are a few methods:1. Email Domain: If your company uses a specific email domain for its employees, you can use this to identify internal users. For example, if the user's email ends with @[yourcompany.com](http://yourcompany.com)
, you can classify them as an internal user.2. User Roles: If your application has a concept of user roles (like 'admin', 'employee', 'customer', etc.), you can use this information to identify internal users. For instance, if a user's role is 'employee' or 'admin', they can be considered as an internal user.3. Specific User Properties: If you have specific user properties that are unique to your internal users, you can use these properties to identify them. For example, if you have a user property like 'department' or 'employee_id' that is only set for internal users, you can use this to identify them.In Mixpanel, you can set these properties as user profile properties. For example, you can set a user profile property like "user_role" for "user type" and Mixpanel joins this information with all events that this user has done within your product. Here is how you can set a user profile property in Javascript::LBKSLBKS```LBKSmixpanel.people.set({
"$email":: "user@yourcompany.com", // user's email
"first_name": "Test", // user's first name
"user_role": "employee" // user's role
});```Once you have these properties set, you can use them to identify internal users and opt them out of tracking as explained in the previous response.For more information, you can refer to the Mixpanel documentation on user profile properties.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
⤵️ Hint: Mention @kapa.ai in the thread for follow-ups.
Hi jtw! Looks like this response could use some human review. I took it upon myself to look at some methods for you to try below. Feel free to look at them and see which works best for you.
Using Data Views: You can create a new data view and filter users based on their email or any other property. Once this is created you can switch between your views from the default “All Project Data”. Docs
Opt Out: If you can identify that the user is internal before you send an event, you can opt users out of tracking in Mixpanel by using the opt_out_tracking() method in Mixpanel’s SDKs. Here is how you can do it in Javascript:
// your logic: if user_is_internal { mixpanel.opt_out_tracking(); // }
Opting out that user will not send any data to Mixpanel servers.
Proxy filter: You can track events using a proxy and filter by IP address in that proxy. This will require implementation of the proxy on your side but we provide some proxy templates to help you get started (nginx and flask). The proxy can read the IP address of the request and not forward the events to Mixpanel based on that criteria.
Enable DNT flag: You can enable DNT flag to all browsers in your organization. Mixpanel does not track users that have the DNT flag enabled in their browser.
Track the IP Address: You can track the IP address to Mixpanel using your own means to detect the IP. Once the IP is detected and tracked as a property, you can exclude that data using filters or data views. However, this method is not recommended due to privacy regulations in some regions.
Block Specific IPs client-side:
const blocked_ip_array = ["ip_address1", "ip_address2", "ip_address3"];
var user_current_ip_address = //YOUR TEAM NEEDS TO FETCH THE IP ADDRESS OF YOUR END USER AND SET THE VARIABLE HERE, YOU COULD USE A SERVICE LIKE IPIFY
if (blocked_ip_array.indexOf(user_current_ip_address) !=== -1) {
mixpanel.register({"$ignore":true});
}
The above should be inserted as soon as the Mixpanel library is initialized so that immediately blocks tracking of undesired IP addresses immediately upon landing. Our library does not fetch or track IP Address, so it will be your responsibility to retrieve the IP address client-side. If not sure how to implement this, you could use a service like ipify: https://www.ipify.org/#:~:text=is%3A%20%24addr%22)-,Javascript,-%3Cscript%20type Hope this helps!