Importing $signup events for existing users
PostedUpdate: The import functionality is now available for all events, and is fully documented in our help section. The below is still a good step-by-step guide for importing $signup events.
Today we are rolling out our new retention tracking system. Now, instead of choosing a user’s cohort on an event-by-event basis (the first time the event was fired) you tell Mixpanel their cohort by sending a $signup event (in fact, this event can be called anything, the key is that you only send it once per distinct_id. If you call it $signup there will be a slight improvement in performance for your report). Usually you would send this event when they first make an account, but a lot of our customers have been asking us about their existing users. How can you tell Mixpanel which cohort to put your current users in?
You can do this, but there are a couple prerequisites:
- You must be already be using mpq.identify() or distinct_id to keep track of your users within Mixpanel
- You must have an existing record tying the identify() or distict_id value you have been sending to Mixpanel with a date you want to use as a user’s birthday. For example: a users table in your database with user_id and date_created fields.
If you meet those prerequisites, you can write a one-off script to send the $signup event to Mixpanel for all your users (each request will count as a Mixpanel data point for billing purposes). To do this, for every user in your database you would make a GET request that looks like this:
This request is very similar to our standard HTTP API (documented here). The data parameter is a Base64 encoded JSON array with the event you are importing ($signup) and the associated properties. By decoding the Base64 data parameter from the above request you can see this:
{u'event': u'$signup',
u'properties': {u'distinct_id': 481,
u'time': 1321499371,
u'token': u'13fe3ddc86eb6f90c4ee7d0d47563150'}}
- The event is $signup
- The ‘distinct_id‘ property is the user ID you have been sending to Mixpanel up to this point for that user. For Javascript Library users – this is the value you put in mpq.identify()
- The time property determines which cohort the user will be in. It is in Unix Epoch format (seconds since 1970). Times should be GMT. The above example, 1321499371, represents November 17th at 3:09 AM GMT.
- The token property is your Mixpanel project token.
There are three differences between this import method and the regular HTTP API:
- this method lets you import events older than 48 hours
- the endpoint is /import/ instead of /track/
- as an added level of security, you must include your API key as a parameter outside the Base64
The /import endpoint works for any events you would like to import – not just the $signup event.
You can download a sample PHP script that you can modify with your own data, token and API key to send $signup events to Mixpanel.
If you have trouble importing $signup events for your current users, please reach out to support@mixpanel.com.
Can you please tell us how to implement this for a new account with no data in MixPanel?