Solved

Fetch data from external list

  • 11 January 2019
  • 2 replies
  • 61 views

Badge

I have several people properties I couldnt set as my mixpanel implementation was made after many users profile were already created at my database.


How can I update mixpanel's people database with my own data? I believe I could do that with python.


My goal is to do somethin like "update AGE where EMAIL is X" and then cross emails from mixpanel database with my own email database


Thanks




icon

Best answer by michael 15 January 2019, 02:25

Hi @afs1987, welcome to Mixpanel Community!

If I were you, I would do this with python using our Mixpanel API Module, and specifically in this case the set properties function.

After you install the module with pip, your script would look something like this:

from mixpanel_api import Mixpanel

if __name__ == '__main__':

 api_secret = ''
 project_token = ''

m = Mixpanel(api_secret,token=project_token, pool_size=4, debug=True)

m.people_set({'Age':'27'},query_params={ 'selector' : '(("@gmail.com" in properties["$email"]) and (defined (properties["$email"])))'})

You would want to edit line 5 and 6 of the above with your api secret and mixpanel project token, and also change the selector to fit your needs.

Taking it one step further for this case, if you have a series of custom age values for corresponding emails, you can utilize a lambda function technique with your people_set (more info here).

Using this method you can iterate over all the dictionary objects in a list of profile distinct_ids and set the property value that is unique to that particular profile.

Anyone else got any ideas?



View original

2 replies

Userlevel 4
Badge +2

Hi @afs1987, welcome to Mixpanel Community!

If I were you, I would do this with python using our Mixpanel API Module, and specifically in this case the set properties function.

After you install the module with pip, your script would look something like this:

from mixpanel_api import Mixpanel

if __name__ == '__main__':

 api_secret = ''
 project_token = ''

m = Mixpanel(api_secret,token=project_token, pool_size=4, debug=True)

m.people_set({'Age':'27'},query_params={ 'selector' : '(("@gmail.com" in properties["$email"]) and (defined (properties["$email"])))'})

You would want to edit line 5 and 6 of the above with your api secret and mixpanel project token, and also change the selector to fit your needs.

Taking it one step further for this case, if you have a series of custom age values for corresponding emails, you can utilize a lambda function technique with your people_set (more info here).

Using this method you can iterate over all the dictionary objects in a list of profile distinct_ids and set the property value that is unique to that particular profile.

Anyone else got any ideas?



Badge

Thanks a lot, Michael. I will try this on my test project and give a feedback.


Reply