Mixpanel super properties are a dictionary of properties stored on the client device that get added to every event before it is sent. Super properties are only for Events, not for properties stored on User Profiles. You can learn more in our article about the difference between super properties and user profile properties.
To implement "incremental super properties" you need to get the super property value from the super property dictionary, add 1 to it, and then re-register the new value for that super property.
iOS Objective-C
Mixpanel *mixpanel = [Mixpanel sharedInstance]; NSDictionary *superProps = [mixpanel currentSuperProperties]; NSNumber *propToIncrement = superProps[@"Some Super Property"]; int value = [propToIncrement intValue]; propToIncrement = [NSNumber numberWithInt:value + 1]; [mixpanel registerSuperProperties:@{@"Some Super Property": propToIncrement}];
iOS Swift
let mixpanel = Mixpanel.mainInstance() let superprops = mixpanel.currentSuperProperties() if (superprops["incrementer"] != nil){ if var i = superprops["incrementer"] as? Int{ i+=1 mixpanel.registerSuperProperties(["incrementer": i]) } }
Android
mixpanel = MixpanelAPI.getInstance(this, projectToken); JSONObject sprops = mixpanel.getSuperProperties(); if (sprops.has("Incrementer")) { try{ int i = sprops.getInt("Incrementer"); i +=1; sprops.put("Incrementer", i); mixpanel.registerSuperProperties(sprops); } catch (JSONException e){ } }
Related post: Incremental super properties
Comments
Article is closed for comments.