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.

Differences Between Last Seen and 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”, which 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"
@interface TrackMixpanelEventWithProperties: NSObject
+ (instancetype)sharedInstance;
- (void)track:(NSString *)event properties:(nullable NSDictionary *)properties;

@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}]; }

Mixpanel recommends 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.

Last Seen Updates 

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 a people profile, a user’s activity feed is not connected to the people datastore.

As a people property, “Last Seen” exists exclusively within 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.

Is this article helpful?
11 out of 24 found this helpful



Article is closed for comments.