If you ever need help, please email us at support@mixpanel.com
Back to topics

Displaying Mixpanel Data to your Users

Updated Sept. 11, 2013
Notice: This API is deprecated. Including $bucket as a property will make your events only available via the API - they will not show up in your reports.

How can I provide Mixpanel data to my users?

Many of our customers have customers of their own, and want to provide their users with analytics. For example, a photo sharing site might want to provide someone who uploaded photos a realtime chart showing how many views their photos are getting.

Sending a bucket id with your events

If this site was already sending an event like "Viewed Photo", they could attach a property to it - $bucket. The presence of one of these properties indicates to Mixpanel that this data belongs in a certain bucket. Most of our customers use your customer's user id to identify the buckets, but you can use any scheme you want. Here is an example event that includes the bucket parameter:

<script type="text/javascript">
    mpq.track("Photo Viewed", {
        "Photo ID": 7369,
        "Camera Type": "Nikkon D700",
        "Date Added": "2011-10-27",
        "Tags": ["happy","exciting","romantic"],
        "$bucket": 982
    });
</script>

As you can see, you can send this bucket information in addition to any other properties you are sending along with the event.

Using the bucket parameter in the data API

To view data for a specific bucket, fetch it using our data export API. For instructions on using our data export API, follow the steps in this tutorial. Except for Segmentation, all API calls support a bucket parameter. Just add that parameter to limit the data to a certain bucket. At this time, you cannot use the $bucket parameter with our Segmentation endpoints.

To pull the counts for the last 31 days of the "Photo Viewed" event mentioned above, broken down by Photo ID, but limiting it to bucket 982, you'd make a call like

Endpoint: http://mixpanel.com/api/2.0/events/properties/
Parameters:
	event:		'Photo Viewed'
	name: 		'Photo ID'
	type:		'general'
	unit:		'day'
	interval:	31
	bucket:		982

As a a properly authenticated API request this would look like:

http://mixpanel.com/api/2.0/events/properties/?sig=c79f20aa7b992449e439cd3a7d6a6aa6
&event=Photo+Viewed&name=Photo+ID&type=general&unit=day&interval=31&bucket=982
&api_key=26a62976f3d5e0448276fc55edadbb1f&format=json&expire=1326527483

You would then receive the data back as a JSON array (or CSV if you specified CSV) and be able to parse it and display it back to your users however you'd like.