Skip to content

Instantly share code, notes, and snippets.

@akkonrad
Created June 7, 2016 10:48
Show Gist options
  • Save akkonrad/3f9439fe22a3928d789776e166e26407 to your computer and use it in GitHub Desktop.
Save akkonrad/3f9439fe22a3928d789776e166e26407 to your computer and use it in GitHub Desktop.
PHP/Mixpanel - mass users update (from csv file exported via JQL)
<?php
$mp = Mixpanel(MIXPANEL_KEY);
$path = '/path/to/user/list.csv';
$row = 1;
if (($handle = fopen($path, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
// skip header line
if ($row++ != 1) {
// $data:
// 0 - Mail
// 1 - $distinct_id
// 17 - Company Type - string
// 18 - Company Field - list
$items = explode(',', $data[18]);
$mp->people->set($data[1], [
'$email' => $data[0],
'Company Type' => $data[17],
'Company Field' => $items
]);
}
}
fclose($handle);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment