Mixpanel - mass removal of old users

I'm going to move on to the next plan in mixpanel to have too many people and would like to delete some old users first.

Is there a simple / script / api way to bulk delete old users?

+9
mixpanel
source share
3 answers

I wrote two scripts that may come in handy; mixpanel-engog-query and mixpanel-eng-post .

Using the first script (query), you can request information about people and get a list of profiles, for example, of all users who have a date older than X months for $ last_seen.

Using the second script (post), you can perform actions on these profiles in batch mode, for example, deleting them. See README for an example of how to perform batch deletion .

+9
source share

Yes there is. Looking at the HTTP specification , you will find the following.

$ remove

string Permanently delete a profile from Mixpanel, as well as all its properties. The value is ignored - the profile is determined by $ distinct_id from the request itself.

// This removes the user 13793 from Mixpanel { "$token": "36ada5b10da39a1347559321baf13063", "$distinct_id": "13793", "$delete": "" } 

Batch requests

Both event endpoints at http://api.mixpanel.com/track/ and the profile update endpoint at http://api.mixpanel.com/engage/ accept batch updates. To send a message packet to the endpoint, you must use POST instead of a GET request. Instead of sending a single JSON object as a data request parameter, send a list of base64 encoded JSON objects as the data parameter for the application's POST request body / x -www-form-urlencoded.

 // Here a list of events [ { "event": "Signed Up", "properties": { "distinct_id": "13793", "token": "e3bc4100330c35722740fb8c6f5abddc", "Referred By": "Friend", "time": 1371002000 } }, { "event": "Uploaded Photo", "properties": { "distinct_id": "13793", "token": "e3bc4100330c35722740fb8c6f5abddc", "Topic": "Vacation", "time": 1371002104 } } ] 

Base64 is encoded, the list will be:

 == 

Thus, the body of the POST request for sending events as a packet:

 data=== 

Both endpoints will receive up to 50 messages in one batch. Typically, batch requests will have the "time" property associated with events, or the "$ time" attribute associated with profile updates.

+8
source share

Using Python Mixpanel-api Module

 pip install mixpanel-api 

This script will delete any profile that has not been viewed since January 1, 2019:

 from mixpanel_api import Mixpanel mixpanel = Mixpanel('MIXPANEL_SECRET', token='MIXPANEL_TOKEN') deleted_count = mixpanel.people_delete(query_params={ 'selector' : 'user["$last_seen"]<"2019-01-01T00:00:00"'}) print(deleted_count) 

Replace MIXPANEL_SECRET and MIXPANEL_TOKEN with your own project tokens.

0
source share

All Articles