Mixpanel

class mixpanel.Mixpanel(token=None, api_key=None, api_secret=None)

Create a Mixpanel service.

Variables:
  • token (str or None) – Optional token used for tracking events. If you leave this as None, you won’t be able to track events through this service object.
  • api_key (str or None) – Optional API key. If you leave this as None, you won’t be able to export data through this service object.
  • api_secret (str or None) – Optional API secret. If you leave this as None, you won’t be able to export data through this service object.

Events

Mixpanel.events()

Return the resource corresponding to events.

Events.get(event, type, unit, interval)
Fetch event data.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#events-default

Events.names(type, limit=None)
Fetch the most common events over the last 31 days.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#events-names

Events.top(type, limit=None)
Fetch the top events for today.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#events-top

Funnels

Mixpanel.funnels()

Return the resource corresponding to funnels.

Funnels.get(funnel_id, from_date=None, to_date=None, length=None, interval=None, unit=None, on=None, where=None, limit=None)
Fetch data for a funnel.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#funnels-default

Funnels.list()
Fetch the list of all funnels.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#funnels-list

Properties

Mixpanel.properties()

Return the resource corresponding to events properties.

Properties.get(event, name, type, unit, interval, values=None, limit=None)
Fetch data of a single event.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#event-properties-default

Properties.top(event, limit=None)
Fetch top property names for an event.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#event-properties-top

Properties.values(event, name, limit=None, bucket=None)
Fetch top values for a property.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#event-properties-values

Retention

Mixpanel.retention()

Return the resource corresponding to retention (cohort analysis).

Retention.get(from_date, to_date, retention_type=None, born_event=None, event=None, born_Where=None, where=None, interval=None, interval_count=None, unit=None, on=None, limit=None)
Fetch cohort analysis.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#retention-default

Segmentation

Mixpanel.segmentation()

Return the resource corresponding to segmentation.

Segmentation.average(event, from_date, to_date, on, unit=None, where=None)
Fetch the average of an expression for an event per time unit.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#segmentation-average

Segmentation.get(event, from_date, to_date, on=None, unit=None, where=None, limit=None, type=None)
Fetch segmented and filtered data for an event.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#segmentation-default

Segmentation.multiseg(event, type, from_date, to_date, inner, outer, limit=None, unit=None)
Fetch the average of an expression for an event per time unit.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#segmentation-multiseg

Segmentation.numeric(event, from_date, to_date, on, buckets, unit=None, where=None, type=None)
Fetch segmented and filtered data for an event, sorted into numeric buckets.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#segmentation-numeric

Segmentation.sum(event, from_date, to_date, on, unit=None, where=None)
Fetch the sum of an expression for an event per time unit.

Upstream documentation: https://mixpanel.com/docs/api-documentation/data-export-api#segmentation-sum

Service methods

Mixpanel.engage(distinct_id, data)

Store people properties

Upstream documentation: https://mixpanel.com/docs/people-analytics/people-http-specification-insert-data

Variables:properties (dict) – The user properties, your access token will be inserted into it automatically.
Returns:A boolean that tells if the event has been logged.
Mixpanel.export(from_date, to_date, event=None, where=None, bucket=None)

Export raw data from your account.

Upstream documentation: https://mixpanel.com/docs/api-documentation/exporting-raw-data-you-inserted-into-mixpanel#export

Variables:
  • from_date (str) – Query start date, in yyyy-mm-dd format.
  • to_date (str) – Query finish date, in yyyy-mm-dd format.
  • event (list of str) – Optional list of events to export.
  • where (str) – A filter expression.
  • bucket (str) – Data bucket to query.
Mixpanel.track(event, properties=None, ip=False, test=False)

Track an event.

Upstream documentation: https://mixpanel.com/docs/api-documentation/http-specification-insert-data

Variables:
  • event (str) – The name of the event.
  • properties (dict) – The event’s properties, your access token will be inserted into it automatically.
  • ip (bool) – Should Mixpanel automatically use the incoming request IP.
  • test (bool) – Use a high priority rate limited queue for testing.
Returns:

A boolean that tells if the event has been logged.