Tracking Browser, Device, and OS
Mixpanel’s Web and Mobile SDKs parseUser-Agent into a set of properties about the user’s browser, device, and OS. This doesn’t happen automatically with server-side tracking, but it’s easy to add these properties yourself.
User-Agent is a header sent on all requests to your server. Most server frameworks provide a way to access your headers:
- Django exposes this as
request.headers["User-Agent"]. - Flask exposes this as
request.headers["User-Agent"]. - Go exposes this in
Headers["User-Agent"]on the http.Request struct. - Nginx exposes this as
$http_user_agent.
Tracking UTMs and Referrer
Mixpanel’s Web SDK parses UTM parameters from the current URL and obtains referrer information from the browser’sdocument.referrer property to enable easy marketing analytics. Since this is not automatic for server-side implementations, these properties will need to be added manually to tracked events. Below is an example in Python:
Tracking Geolocation (Server-side)
By default, Mixpanel uses the IP address of the request to set geolocation properties. If you’re tracking from your server, you need to override the IP property of your events and profile updates from your server’s IP address to the client’s IP address. Read our full guide on managing geolocation.Tracking Page Views
Page view tracking must be done manually for server-side implementations. Here are some general guidelines for tracking page views.- Track page views as a single event type by using a constant
event_name - Track different pages as an event property and not as different events for better analysis
- Plan ahead for handling page views from anonymous users, identified users, and connecting them to merge a user’s journey
- Get started below with Identifying Users
- Fire page view events only on successful responses to the client
- Parse headers and the request URL for common web analytics properties such as referrer and UTM parameters
- See above for parsing user agent and marketing attribution properties