Skip to content
Official ruby client interface to the Mixpanel Data API
Latest commit 52cb38f Sep 29, 2015 @keolo Updated changelog.:
Failed to load latest commit information.
lib Bump version. Sep 29, 2015
manual_test Bump version and did some cleanup. Mar 15, 2014
spec Removes typhoeus version lock, fixes a "broken" test. Apr 23, 2015
.document Initial commit to mixpanel_client. Nov 10, 2009
.gitignore Gem updates. Aug 30, 2013
.rubocop.yml Bump version and did some cleanup. Mar 16, 2014
.rvmrc Update to ruby 2.0. Mar 15, 2014
Gemfile Using the 'Bundler' method for managing gem. Mar 12, 2011
Rakefile Updated changelog.: Sep 29, 2015
license Forevva. Mar 15, 2014
mixpanel_client.gemspec Minor copy update. Apr 30, 2015 Use svg version of badge. May 1, 2015

Mixpanel Data API Client

Gem Version Code Climate

Ruby access to the Mixpanel web analytics tool.

Mixpanel Data API Reference


gem install mixpanel_client

or if you use a Gemfile

gem 'mixpanel_client'


require 'rubygems'
require 'mixpanel_client'

client =
  api_key:    'changeme',
  api_secret: 'changeme'

data = client.request(
  event:     'splash features',
  name:      'feature',
  values:    '["uno", "dos"]',
  type:      'unique',
  unit:      'day',
  from_date: '2013-12-1',
  to_date:   '2014-3-1',
  limit:     5

puts data.inspect

# The API also supports passing a time interval rather than an explicit date range
data = client.request(
  event:    'splash features',
  name:     'feature',
  values:   '["uno", "dos"]',
  type:     'unique',
  unit:     'day',
  interval: 7,
  limit:    5

# Use the import API, which allows one to specify a time in the past, unlike the track API.
# note that you need to include your api token in the data. More details at:
data_to_import = {'event' => 'firstLogin', 'properties' => {'distinct_id' => guid, 'time' => time_as_integer_seconds_since_epoch, 'token' => api_token}}
require 'base64' # co-located with the Base64 call below for clarity
encoded_data = Base64.encode64(data_to_import.to_json)
data = client.request('import', {:data => encoded_data, :api_key => api_key})
# data == [1] # => true # you can only import one event at a time


You may also make requests in parallel by passing in the parallel: true option.

require 'rubygems'
require 'mixpanel_client'

client =
  api_key:    'changeme',
  api_secret: 'changeme',
  parallel:   true

first_request = client.request(

second_request = client.request(

third_request = client.request(



puts first_request.response.handled_response
puts second_request.response.handled_response
puts third_request.response.handled_response


List of rake tasks.

rake -T

Run specs.

rake spec

Run external specs.

cp config/mixpanel.template.yml config/mixpanel.yml
vi config/mixpanel.yml
rake spec:externals

Run rubocop and fix offences.




Collaborators and Maintainers



Copyright (c) 2009+ Keolo Keagy. See license for details.

Something went wrong with that request. Please try again.