Community Tip: Incremental Super Properties - Mixpanel
Blog Post

Community Tip: Incremental Super Properties

Last edited: Dec 10, 2017

This Community Tip will outline how to create incremental super properties using our JavaScript SDK, so you can keep a tally of how often a user takes specific actions on your site or in your app and then segment any event by count.

What Makes A Super Property So Super?

Before we dive in to incremental super properties let’s have a quick reminder of what super properties are. Super properties are client-side properties that are automatically attached to every event that a user sends to your Mixpanel project. They make working with Mixpanel data much more convenient because they act as global properties that are omnipresent in all your events (given that the cookie is not cleared). Some examples of information that you may want to attribute to every event are ad campaign, signup date, or paid account type, etc. It’s important to note that super properties are only for events, not for profiles within People Analytics.

Take it A Step Further

Now, sometimes you may want to create a tally that counts the number of times a user has done something specific in your app. For example, if you are an e-commerce site you may want to keep track of how many times a user has viewed an item, how many items they’ve added to their cart, or how many purchases they’ve made. It could be very useful to look at other events in association with those metrics. Perhaps the majority of purchases come from users that have viewed an item more than 3 times. That is exactly the type of information you can glean using incremental super properties!

Implementing Incremental Super Properties

There isn’t currently a method in Mixpanel’s libraries for making incremental super properties so creating them requires a bit of extra work – but it’s worth it!
We’ll be creating a custom snippet that will grab the super property we want to increment from the cookie, update its current value by the increment amount, and register it as a super property again.

First, we’ll initialize the property. Then, when appending we’ll grab the property from the cookie with mixpanel.get_property(). Finally, you’ll add your desired addition and use mixpanel.register() to overwrite the property with the new values. Here’s a simple example of a custom Javascript snippet that illustrates one way to go about this, this would be inserted adjacent to the Mixpanel library in the head of your site:

//define the incrementing function
incrementer = function(property) {
  value = mixpanel.get_property(property);
  update = {}
  if(value && typeof(value) == 'number') {
    update[property] = value +1;
  else {
    update[property] = 1

Now that we’ve got our Javascript ready to grab the super property from the cookie and increment we’re nearly finished, but there’s one more step! In order to use the mixpanel.get_property() function we’ll need to use the Mixpanel library’s loaded callback to ensure that the library is fully loaded.

The Mixpanel JavaScript library loads asynchronously to prevent the script from blocking other processes from running on your web application. This is important, because the mixpanel.get_property() method is not available until the Mixpanel library is fully loaded. To ensure that this isn’t an issue, we’ll need to pass a config object to the mixpanel.init() method with a loaded parameter and a callback function that will execute immediately after the library loads. Here is an example of what our loaded callback would look like:

    mixpanel.init("YOUR TOKEN", {
    'loaded' : function() {
            incrementer('incremented property');

Once you have the incremental super property set you can leverage this property across all of your Engagement reports. Returning to the e-commerce example – you could create a Funnel report examining the process of user’s searching, adding items to their cart, and ultimately purchasing an item and see the number of times users did each step before moving on to the next. Or perhaps, you want to create a Retention report that shows how well users move from adding an item to their cart to actually purchasing – specifically for first time users vs. seasoned users.

Incremental super properties are a great tool to explore how your users engage differently with your app as they become more familiar with firing specific events.

Have any questions about super properties or how to increment them? Reach out to to speak to someone smart, quickly.

Related article: How do I implement super properties on mobile?


Get the latest from Mixpanel
This field is required.