I too was wondering on how to do this, based on Mixpanel's article (https://mixpanel.com/blog/2014/07/21/revenue-best-practices). I did a lot of back and forth with Segment's tech support, and after a couple of days of repeatedly telling them to read the article, they finally got me to an engineer who actually read it, and was able to answer my question about this as well. Here's his answer:
It looks like a few things need to happen for this lifetime revenue value to be tracked.
First, track_charge
needs to be called. Fortunately we're already firing a track_charge
call when revenue is passed as a trait in track calls. You can see where that happens in the code here.
Secondly, a the people.increment()
needs to be called. We also fire this on the page as you can see here, but it doesn't look like we currently have a way to pass through the revenue in that people.increment
call.
Looks like your best bet here would be to fire off the increment and set calls directly. As you may know, we're loading the Mixpanel library on the page so all you have to do is execute the calls within an analytics.ready()
method. Doing so ensures that the native calls only fire when the Mixpanel library has properly loaded on the page.
For reference, here are the calls you'd want to place within the ready()
method.
mixpanel.people.increment("Lifetime Value", 27);
mixpanel.people.set("Last Item Purchase", new Date.toISOString());