rmixpanel is the R client for Mixpanel API, use this tool if you need load data from Mixpanel API into R.
For convenience of searching functions of rmixpanel, each function have prefix “MP.”.
You can get detailed help about each of package function by help command, for example if you need help about MP.getRawData function you can run help("MP.getRawData").
In order to get list of all available rmixpanel fuction use help(package = "rmixpanel").
Install rmixpanel
You can instal rmixpanel from GitHub repository, for this run next code in R console.
You can be found your api secret by clicking on your name in the upper righthand corner under Project Settings.
API Secret is a require argument of each rmixpanel functions.
Sing in mixpanel using your login and password.
Chose “Accounts” in main menu.
Go to tab “Projects”, and copy API Secret of your project.
rmixpanel functions
Name
Description
MP.getEvents
Get unique, total, or average data for a set of events over N days, weeks, or months.
MP.getEventsProperty
Get unique, total, or average data for of a single event and property over days, weeks, or months.
MP.getRetention
Get cohort analysis.
MP.getRawData
Get a "raw dump" of tracked events over a time period.
MP.getEvents - Get unique, total, or average data for a set of events over N days, weeks, or months.
Arguments
api_secret - Your API Mixpanel secret, you can find hin in mixpanel web interface: Account (http://img.netpeak.ua/alsey/150600941068_kiss_10kb.png) > Projects (http://img.netpeak.ua/alsey/150600948369_kiss_46kb.png).
event - Character vector, the event or events that you wish to get data for, example c(“play song”, “log in”, “add playlist”).
type - The analysis type you would like to get data for - such as general, unique, or average events. Valid values:
“general” - Total events number
“unique” - Number of unique users commit event
“average” - Average events number on user
unit - It determines the level of granularity of the data you get back. Note that you cannot get hourly uniques, Valid values:
“minute” - Group by minutes
“hour” - Group by hours
“day” - Group by date
“week” - Group by week
“month” - Group by month
interval - The number of “units” to return data for - minutes, hours, days, weeks, or months. 1 will return data for the current unit (minute, hour, day, week or month). 2 will return the current and previous units, and so on. Specify either interval or from_date and to_date.
from_date - The first date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
to_date - The last date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
Example
Get total number of event “posting_success”,”emu”,”session_start”,”$custom_event:585946” from 1 june of 2017 till 25 july of 2017, with group by day.
MP.getEventsProperty - Get unique, total, or average data for of a single event and property over days, weeks, or months.
Arguments
api_secret - Your API Mixpanel secret, you can find hin in mixpanel web interface: Account (http://img.netpeak.ua/alsey/150600941068_kiss_10kb.png) > Projects (http://img.netpeak.ua/alsey/150600948369_kiss_46kb.png).
event - Character vector, the event or events that you wish to get data, for example c(“posting_success”,”emu”,”session_start”,”$custom_event:585946”.
property - The name of the property you would like to get data for. For example “mp_country_code”.
values - The specific property values that you would like to get data for Example: If you have a property “gender” you may have values “male”, “female” and “unknown”. If you just want data for female and unknown users, you can include a values property that looks like “[“female”, “unknown”]”.
type - The analysis type you would like to get data for - such as general, unique, or average events. Valid values:
“general” - Total events number
“unique” - Number of unique users commit event
“average” - Average events number on user
unit - It determines the level of granularity of the data you get back. Note that you cannot get hourly uniques, Valid values:
“minute” - Group by minutes
“hour” - Group by hours
“day” - Group by date
“week” - Group by week
“month” - Group by month
interval - The number of “units” to return data for - minutes, hours, days, weeks, or months. 1 will return data for the current unit (minute, hour, day, week or month). 2 will return the current and previous units, and so on. Specify either interval or from_date and to_date.
tidy - Logical, if TRUE apply tidy data format, if FALSE apply report data format.
from_date - The first date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
to_date - The last date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
limit - The maximum number of values to return.
Example
Get total umber of event “$custom_event:585946” from 1 june of 2017 till 25 july of 2017, with group by day and property mp_country_code.
api_secret - Your API Mixpanel secret, you can find hin in mixpanel web interface: Account (http://img.netpeak.ua/alsey/150600941068_kiss_10kb.png) > Projects (http://img.netpeak.ua/alsey/150600948369_kiss_46kb.png).
event - Character vector, the event or events that you wish to get data, for example c(“posting_success”,”emu”,”session_start”,”$custom_event:585946”.
retention_type - Must be either “birth” or “compounded”. Defaults to “birth”. For example “compounded”.
born_event - The first event a user must do to be counted in a birth retention cohort. Required when retention_type is “birth”; ignored otherwise.
born_where - An expression to filter the returning events by. For example ‘properties[“utm_source”]==”AdWords” and “Brand” in properties[“utm_campaign”]’, For more information go link.
where - An expression to filter the returning events by. For example ‘properties[“utm_source”]==”AdWords” and “Brand” in properties[“utm_campaign”]’, For more information go link.
unit - It determines the level of granularity of the data you get back. Note that you cannot get hourly uniques, Valid values:
“minute” - Group by minutes
“hour” - Group by hours
“day” - Group by date
“week” - Group by week
“month” - Group by month
interval - The number of “units” to return data for - minutes, hours, days, weeks, or months. 1 will return data for the current unit (minute, hour, day, week or month). 2 will return the current and previous units, and so on. Specify either interval or from_date and to_date.
interval_count - The number of intervals you want; defaults to 1. Note that we include a “0th” interval for events which take place less than one interval after the initial event.
on - The property expression to segment the second event on. See the expressions section above, for example ‘properties[“utm_source”]’.
tidy - Logical, if TRUE apply tidy data format, if FALSE apply report data format.
from_date - The first date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
to_date - The last date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
Example
Get cohort analisys by event “$custom_event:585946” from 1 june of 2017 till 25 july of 2017, with week steps
retension<-MP.getRetention(api_secret="hgf7fi437nhdsad7863y98ryn988h8",event="emu",retention_type="birth",unit="week",born_event="session_start",where='properties["utm_source"]=="AdWords" and "Brand" in properties["utm_campaign"]',interval_count=4,from_date="2017-08-01",to_date="2017-09-25")
Get cohort analisys by week, in last four weeks from 1 august of 2017, and segmentation cohort by propery utm_source.
MP.getRawData - Get a “raw dump” of tracked events over a time period..
Work duration of this function is too long and use him only if you can’t get data using another functions.
Example usage cases
If you receive a spike of 10K events but notice that only a few users contributed to it and would like to dive deeper into the data.
If you are buying mobile ads and would like to dive deeper into the exact UDIDs and see who you really can attribute to the install.
If you are doing some very custom analysis Mixpanel cannot currently do. If this is the case, please email support@mixpanel.com so we can either improve our product or possibly show you how you can do it with us.
Arguments
api_secret - Your API Mixpanel secret, you can find hin in mixpanel web interface: Account (http://img.netpeak.ua/alsey/150600941068_kiss_10kb.png) > Projects (http://img.netpeak.ua/alsey/150600948369_kiss_46kb.png).
event - Character vector, the event or events that you wish to get data, for example c(“posting_success”,”emu”,”session_start”,”$custom_event:585946”.
where - An expression to filter the returning events by. For example ‘properties[“utm_source”]==”AdWords” and “Brand” in properties[“utm_campaign”]’, For more information go link.
from_date - The first date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
to_date - The last date to return data for, in yyyy-mm-dd format. This date is inclusive. Specify either interval or from_date and to_date.
Example
Get all events emu with all his properties from 10 july 2017 года, only by utm_source is AdWords, and campaign name constain “Brand”.
MixPanel.RawData<-MP.getRawData(api_secret="hgf7fi437nhdsad7863y98ryn988h8",event="emu",where='properties["utm_source"]=="AdWords" and "Brand" in properties["utm_campaign"]',from_date="2017-07-10",to_date="2017-07-10")
Get all events with all properties from 1 september 2017 till 10 september 2017.