Skip to content

Instantly share code, notes, and snippets.

@TOAST3R
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TOAST3R/9483413 to your computer and use it in GitHub Desktop.
Save TOAST3R/9483413 to your computer and use it in GitHub Desktop.
Get data from mixpanel
#Install ruby
require 'rubygems'
require 'mixpanel_client'
#How to get totals visitors:
config = {api_key: 'changeme', api_secret: 'changeme'}
client = Mixpanel::Client.new(config)
data = client.request('segmentation', {
event: 'Kelisto',
from_date: '2014-01-01',
to_date: '2014-03-01',
values: ['Direct', 'SEO Content', 'SEO Generic', 'SEO Community', 'SEM Branded'],
on: 'properties["last_touch_source"]'
type: 'general',
unit: 'minute',
})
puts data.inspect
#How to get conversions from Car Insurance Process
props = {
event: "Car insurance process view",
from_date: '2014-01-01',
to_date: '2014-03-01',
on: 'properties["last_touch_source"]',
type: 'general',
unit: 'minute'
}
props.merge!({where: 'properties["Page name CI"] == "Provider Redirect"'}) unless where.nil?
data = client.request('segmentation', props)
puts data.inspect
#How to get conversions from Communications product
props = {
event: "Page interaction",
from_date: '2014-01-01',
to_date: '2014-03-01',
on:'properties["last_touch_source"]',
type: 'general',
unit: 'minute'
}
props.merge!({where: '"communications" in properties["Referral type"]'})
data = client.request('segmentation', props)
puts data.inspect
#How to get conversions from Finances product
props = {
event: "Page interaction",
from_date: '2014-01-01',
to_date: '2014-03-01',
on: 'properties["last_touch_source"]',
type: 'general',
unit: 'minute'
}
props.merge!({where: '"personal-finance" in properties["Referral type"]'})
data = client.request('segmentation', props)
puts data.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment