Created
June 7, 2016 10:48
-
-
Save akkonrad/3f9439fe22a3928d789776e166e26407 to your computer and use it in GitHub Desktop.
PHP/Mixpanel - mass users update (from csv file exported via JQL)
This file contains 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
<?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