Yossi Vainshtein
Yossi Vainshtein

Reputation: 3985

how to get total number of mixpanel events via API

Can I get total number of events (=data points) for a time period?

The 'events' method (http://mixpanel.com/api/2.0/events/) seems almost what I need, it's just that it requires a list of event names, and I need the total count of my events, I do not have the names.

I could not find this one in the API.

Upvotes: 0

Views: 1334

Answers (2)

samjewell
samjewell

Reputation: 1178

You can use the JQL console within Mixpanel, under the "Applications" menu in the left-nav. Just run the following, and it'll count the total number of events. See the JQL API reference here: https://mixpanel.com/help/reference/jql/api-reference#api/concepts

function main() {
  return Events({
    from_date: '2010-02-02',
    to_date:   '2017-02-03'
  }).reduce(mixpanel.reducer.count());
}

// 989322

Upvotes: 0

ryanseams
ryanseams

Reputation: 11

You can first hit the events by name API to return the list of your events at http://mixpanel.com/api/2.0/events/names/. Then, you can pump the return as a list into your request to http://mixpanel.com/api/2.0/events/ to get the count for each of your events.

Depending on your usage case, it may make more sense to use a URL hack on the main segmentation report instead of hitting the API. If you add union:1 as a new parameter to the URL (they are comma separated at the end) the report will display the union of all your events over a time period -- if you are viewing totals, this will be the total event count.

Upvotes: 1

Related Questions