Last active
August 29, 2015 13:57
-
-
Save TOAST3R/9483413 to your computer and use it in GitHub Desktop.
Get data from mixpanel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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