I am using Mixpanel server side. when setting the $email user profile property, can I pass the IP address so that it automatically sets the geolocation too ?
Hi Zeyad Y., 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, you can pass the IP address when setting the $email user profile property server-side to automatically set the geolocation. However, there are a few important points to consider: 1. IP Address Property: For profile updates, you need to use $ip
(not ip
) to specify the IP address.2. Geolocation Parsing: Mixpanel will use the provided IP address to parse and set the geolocation properties ($city, $region, $country_code) for the user profile.3. IP Address Discarded: The IP address itself is not stored by Mixpanel. It's only used to derive the geolocation data and then discarded.Here's an example of how you might set this up in PHP (adjust for your specific server-side language): LBKS$mp-> people-> set("USER_ID", array( '$email' => 'user@​[example.com](http://example.com)', '$ip' => '136.24.0.114' // Replace with actual user IP ));LBKS
It's important to note that if you're tracking from your servers, you need to set the $ip
property to the client's IP address, not your server's IP. Most server frameworks provide ways to get the client's IP address.Geolocation: IP address and location properties provides more details on this topic.Remember, if you don't want to update geolocation at all, you can set $ip
to 0: LBKS$mp-> people-> set("USER_ID", array( '$email' => 'user@​[example.com](http://example.com)', '$ip' => '0' // Prevents geolocation update ));LBKS
This approach allows you to set the email property without affecting the user's geolocation data.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.