How do I import revenue data?

If you’re on a Startup, Business, or Enterprise plan, leverage the Mixpanel Revenue report to track total revenue numbers as well as customer lifetime value and revenue per paying user. How you import revenue data depends on whether you are trying to import revenue as a Property of a purchase Event or import transactions for use in Mixpanel’s Revenue report.

See revenue best practices to decide how you want to import your data.

Import data to populate Mixpanel’s Revenue report

Mixpanel tracks Revenue using a People Property called $transactions , which is a list containing specially formatted JSON objects, one for each purchase or transaction associated with the particular profile. Because the Property is a list of JSON objects, it’s not possible to use the built-in CSV upload feature in Explore to import Revenue data.

However, you can import Revenue data and have future mixpanel.track_charge calls increment correctly moving forward by sending the data as base-64 encoded $transactions objects to the Engage endpoint using $append .

For example, to import a transaction by the user with distinct id "123" for $20 at 9AM on January 3rd, 2016, you would send the following:

{
"$append": {
"$transactions": {
"$time": "2016-01-03T09:00:00",
"$amount": 20.00
}
},
"$token": "<your project token>",
"$distinct_id": "123"
}

Encoded and ready to be sent to the endpoint, it will look like this:

http://api.mixpanel.com/engage/?data=ew0KIiRhcHBlbmQiOiB7DQoiJHRyYW5zYWN0aW9ucyI6IHsNCiIkdGltZSI6ICIyMDE2LTAxLTAzVDA5OjAwOjAwIiwNCiIkYW1vdW50IjogMjAuMDANCn0NCn0sDQoiJHRva2VuIjogIjx5b3VyIHByb2plY3QgdG9rZW4+IiwNCiIkZGlzdGluY3RfaWQiOiAiMTIzIg0KfQ0K

See more documentation on tracking revenue.

Because the $transactions Property can’t be used like other Properties as a filter (specifically for targeting notifications), it’s also a good idea when tracking revenue to create an additional People Property called “Lifetime Revenue” (or similar) that you can use for filtering.