URI: http://api.mixpanel.com
Description
Endpoint: /track
Logs event based data to our servers, both GET and POST are permitted. We strongly encourage you to use non-blocking solutions such as a queue service like RabbitMQ. Storage, processing, and analysis are done after the request is received.
Example
http://api.mixpanel.com/track/?data=eyJldmVudCI6ICJnYW1lIiwgInByb3BlcnRpZXMiOiB7ImlwIjogIjEyMy4xMjMuMTIzLjEyMyIsICJ0b2tlbiI6ICJlM2JiNDEwMDMzMGM
zNTcyMjc0MGZiOGM2ZjVhYmRkYyIsICJ0aW1lIjogMTI0NTYxMzg4NSwgImFjdGlvbiI6ICJwbGF5In19&ip=1
This is a Base64 encoded JSON dictionary/associative array that takes on the structure of:
{"event": "game", "properties": {"ip": "123.123.123.123", "token": "e3bc4100330c35722740fb8c6f5abddc", "time": 1245613885, "action": "play"}}
Note: Also please be aware our flavor of base64 includes the following characters: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
Response
Special properties
Mixpanel has some reserved properties that cannot be used, if they are, they will simply be ignored or overwritten.
Properties prefixed with 'mp_' will be ignored during data analysis. You should refrain from using properties like this completely.
Additionally, there are reserved properties that are available for your use but will not be shown to you during analysis:
- time is the time at which the event occured, it must be a unix timestamp, requests will be rejected that are 3 hours older than present time. Format is seconds since 1970, GMT time zone.
- distinct_id is any string that uniquely can identify a user. You can pass user ids as well.
- token is the token we provide when you create your project, it's located in your dashboard.
- ip is a raw string IP Address (e.g. "127.0.0.1") that you pass to our API. This is largely useful if you're making requests from your backend and would like geolocation processing done on your requests otherwise it's safe to use the &ip=1 parameter described in the docs that is outside of the encoded data string.
Parameters
| Required | Name | Type | Description |
| required | data | string | This is a Base64 encoded JSON encoded dictionary/associative array. The JSON encoded string should be in this format: {'event' : 'YOUR_EVENT', 'properties' : {'key' : 'value', 'key' : 'value'}} Where 'event' is a user defined string. Properties are a simple json object of key-value based pairs whose keys and values can be any string. |
| Parameter tricks | |||
| optional | ip | boolean (0 or 1) | Will automatically utilize the IP address from an incoming request as the substitute for the distinct_id parameter if one is not specified. Setting this to 1 will override any IP Address usage in properties. |
| optional | redirect | string | Redirect can take any URL address and log metric data based on the values and parameters specified and then redirect a user to any location desired (such as back to your web application). This is useful in situations where you are more restricted and need to track conversions on things. |
| optional | img | boolean (0 or 1) | This parameter takes either 1 or 0 as its value and will display a 1x1 transparent pixel image if used in conjunction with a <img> tag while logging metric data based on any parameters specified above. This is useful, like redirect, in situations where you are more restricted. For example, you could log when users open up bulletins on MySpace by inserting this 1x1 pixel image and track which user sent the bulletin that was opened as well. This can also be used as a non-blocking substitute for certain situations. Simply append the &img=1 parameter to enable this. |
| optional | callback | string | Used for jsonp to callback some function in your javascript with the API's response. |
| optional | test | boolean (0 or 1) | Passing 1 to this parameter will let you test the API but data will not be logged to our servers. |
Funnel
This section outlines how to do funnel analysis based tracking with our REST interface.
Funnel based tracking harnesses the use of properties to make things simple. The event mp_funnel is used to tell Mixpanel that a funnel is being tracked. The following property keys are reserved specifically for the event mp_funnel: step (int), funnel (string), and goal (string).
- step is an integer of sequential step in the funnel, all funnels start at step 1.
- funnel is a string, identifies which funnel data is attached to, step and goal are linked to this.
- goal is a string and is a semantic link to the step number. goals for a certain funnel and step should always be the same as we do not track different goals for the same step and funnel yet.
Example of a json string
{"event": "mp_funnel", "properties": {"ip": "123.123.123.123", "token": "e3bc4100330c35722740fb8c6f5abddc", "time": 1245613885, "gender": "male", "funnel": "My Funnel", "step": 1, "goal": "Impression"}}
