What is "Last Seen"?

What is “Last Seen”?

“Last Seen” ($last_seen) is a reserved People property that records the date of the most recent update to a given People profile. This property is not automatically updated when events are tracked, only when a people profile is updated.

The “Last Seen” property should never be manually updated or imported.

What if I would like “Last Seen” to reflect a user's “Last Event”?

Depending on the context of your project, you might prefer to tailor your implementation to include a custom date People property such as “Last Login” that would update each time a user fired a “Login” event. This People update would automatically prompt an update to Last Seen and additionally allow you to send event-based targeted Notifications to users who had logged in even more than 90 days ago.

If you want the "Last Seen" property to reflect the timestamp of the last event fired, for every track call in your code, you could use a people.set call to track the date the user's “Last Activity” as a custom people property.

To make this efficient, you can tailor your implementation to track the "Last Event" each user completed once they authenticated by creating a wrapper that automatically tracks an event and made a people set call. This will ensure that “Last Seen” reflects the timestamp of a user’s last authenticated event.

An example class for an iOS app can be found below:

#import "Mixpanel.h"
NS_ASSUME_NONNULL_BEGIN
@interface TrackMixpanelEventWithProperties: NSObject
+ (instancetype)sharedInstance;
- (void)track:(NSString *)event properties:(nullable NSDictionary *)properties;
@end

@implementation TrackMixpanelEventWithProperties
+(instancetype)sharedInstance { static dispatch_once_t onceToken; static TrackMixpanelEventWithProperties *globalStatic = nil; dispatch_once(&onceToken, ^{ globalStatic =[[TrackMixpanelEventWithProperties alloc] init]; }); return globalStatic; }
-(void)track:(NSString *)event properties:(nullable NSDictionary *)properties{ [[Mixpanel sharedInstance]track:event properties:properties]; [[Mixpanel sharedInstance].people set:@{@"Last Event":event}]; }
@end
NS_ASSUME_NONNULL_END

We recommend ONLY using this method described above for events that occur after you have identified the user. Setting people properties before the login stage can create a large number of anonymous profiles.

Why is “Last Seen” not automatically updated when a user fires an event?

Your Mixpanel data is split into two platforms: Engagement and People. Your Engagement data is comprised of all your events, while your People data is comprised of your People profiles. Given the disparate types of data, Engagement data (events) and People data (profiles) live in two entirely separate datastores.

A user’s Activity Feed groups all events fired by a particular distinct_id and is populated from Mixpanel’s Engagement data. While you can view a user’s Activity Feed within his/her People profile, a user’s Activity Feed is not connected to the People datastore. As a People property, “Last Seen” exists exclusively within your People data. Consequently, a user firing an event and hitting our Engagement API does not trigger an update to a user’s Last Seen People property.