The user level location property in my mixpanel project is getting set as same for all the users - Mumbai - which is also the location of my server. Mostly It's because mixpanel is taking the IP from the request which is the location of our servers. How can I forward the IP coming from the client to Mixpanel via backend, Backend runs on PHP laravel
Yes. In the PHP SDK, people-> set($distinct_id, $properties, $ip) accepts the IP as the optional third argument. Pass the client’s IP there (or 0 to ignore geolocation). [PHP storing profiles; Define IP address]
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.
Let me check the knowledge base for you again. One moment! 📚
So the IP should be the third argument in people->set() function, right
You’re right—when sending data server-side, Mixpanel will use your server’s IP unless you override it, causing all profiles to show your data center location. In PHP/Laravel, forward the client’s IP in your payload so Mixpanel geolocates based on the user rather than the server.Options: - Best: pass the client IP in your profile and event payloads - For profile updates, set $ip (outside $set):
'name' => 'Samantha',
], $ip = $request-> ip()); // or your trusted client IP extraction
```LBKS This ensures the Engage API uses the client IP for profile geolocation. [[Define IP address](https://docs.mixpanel.com/docs/tracking-best-practices/geolocation#define-ip-address); [PHP storing profiles](https://docs.mixpanel.com/docs/tracking-methods/sdks/php#storing-user-profiles)]
- For events, set ip in properties (or set events_endpoint to include ip automatically per request):
```LBKS $mp-> track('Signed Up', [
'distinct_id' => $distinctId,
'ip' => $request-> ip(), // or your trusted header logic
]);
```LBKS Mixpanel will replace ip with $city, $region, mp_country_code during ingestion. [[Import GeoIP enrichment](https://github.com/mixpanel/docs/blob/main/reference/Ingestion%20API/events/import-events.md); [Default properties](https://docs.mixpanel.com/docs/data-structure/property-reference/default-properties)]LBKS- If you can’t reliably get the client IP, manually set geolocation properties instead:
- Events: mp_country_code, $region, $city
- Profiles: $country_code, $region, $city
These override IP-derived geolocation. [[Manual geolocation](https://docs.mixpanel.com/docs/tracking-best-practices/geolocation#manual-geolocation-tracking)]LBKS- If you prefer to avoid any geolocation updates from server calls, disable it:
- Profiles: pass $ip = 0 on people-> set
- Events: initialize PHP SDK with "events_endpoint" => "/track?ip=0"
[[PHP privacy-friendly](https://docs.mixpanel.com/docs/tracking-methods/sdks/php#privacy-friendly-tracking); [Define IP address](https://docs.mixpanel.com/docs/tracking-best-practices/geolocation#define-ip-address)]LBKSLaravel tip for client IP:
- Use $request-> ip() if your app is correctly behind a trusted proxy; otherwise configure TrustedProxy to safely read X-Forwarded-For. Then pass that value as shown above. (The sources don’t cover Laravel specifics, but the principle is to set ip/$ip to the end-user IP.) [[Server-side best practices](https://docs.mixpanel.com/docs/tracking-best-practices/server-side-best-practices)]LBKSWhy this works:
- Mixpanel derives geolocation from ip/$ip; passing the client IP fixes the “all users show server location” issue. [Geolocation overview; Troubleshooting FAQ]
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.
Hi Anshul S., 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