If you ever need help, please email us at support@mixpanel.com
Back to topics

How do I set a property every time?

Updated March 20, 2013

This article assumes you at least understand properties and only covers event-based tracking. For more on properties, read our tutorial. For the full spectrum of user-specific properties, please read Managing User-Specific Properties.

Super Properties

Super properties allow you to continuously attach a property to every event you track automatically. They make segmenting within Mixpanel more convenient because they act as global properties that get attached to all your events. Super properties are only for events, not profiles within People Analytics.

Some examples of these are:

  • User type (free/paid?)
  • Account age
  • Gender
  • Ad-campaign

By registering these as super properties, you will be able to segment each event by any of them without specifically including them as event properties every time.

Registering super properties to a user is very simple. By default, super properties are included with all events and funnels, but it is possible to only include them with events or only with funnels.

Syntax

Here's a breakdown of the function and its parameters. We'll show an example implementation in a moment.

/*
 *  @required properties (hashmap) - Extra information to store about a user.
 *  @days (int) - Age of cookie in days (default: 365). 
                  The cookie set frequently so this has little effect.
 *                  
 *  Example:
 */
 
mixpanel.register({'user type': 'free trial'}, 100);

Example

Now for an example implementation. There are a couple of places it makes sense to register super properties: on page load, if you have the data about your users already, and at the time of an individual event if that event tells you more about them.

If I want to register super properties on page load, it will look something like this:

<script type="text/javascript">
    (function(d,c){var a,b,g,e;a=d.createElement("script");a.type="text/javascript";
    a.async=!0;a.src=("https:"===d.location.protocol?"https:":"http:")+
    '//cdn.mxpnl.com/libs/mixpanel-2.0.min.js';b=d.getElementsByTagName("script")[0];
    b.parentNode.insertBefore(a,b);c._i=[];c.init=function(a,d,f){var b=c;
    "undefined"!==typeof f?b=c[f]=[]:f="mixpanel";g=['disable','track','track_links',
    'track_forms','register','register_once','unregister','identify','name_tag','set_config'];
    for(e=0;e<g.length;e++)(function(a){b[a]=function(){b.push([a].concat(
    Array.prototype.slice.call(arguments,0)))}})(g[e]);c._i.push([a,d,f])};window.mixpanel=c}
    )(document,[]);
    mixpanel.init("YOUR_TOKEN");

    // Register a super property
    mixpanel.register({"user type": "paid", "gender": "male"});
</script>

If I want to register the super property after an event has occurred, it's just as easy. Let's say that the user just signed up for an account and I want to tag them with their account type.

<script type="text/javascript">
function create_account() {
    ...
    mixpanel.register({"account type": "premium"});
}
</script>

Then, when I log an event or funnel these super properties will be automatically included. If I were to call

mixpanel.track('button click');

it would actually be sent to the server as

mixpanel.track('button click', {"user type": "noob", "gender": "male", "account type": "premium"});

This allows you to segment the 'button click' event by user type, gender, and account type with no extra effort. Using super properties drastically simplifies the rest of the integration process.

Using our javascript library, super properties only have to be registered at least once per visitor as we will persist the super properties across page loads later using cookies.

Super properties and events

If you want certain super properties to only show up for events, and not funnels, you just register them with the "events" type.

mixpanel.register({"account type": "pro", "ad" : "pepsi"}, "events");

For this example, the 'account type' and 'ad' super properties would be passed along with normal events, but not with your funnels.

Super properties and funnel analysis

Super properties let you register properties (such as referrer or ad campaign) once at the beginning of your funnel, but see them for every step.

mixpanel.register({"ad campaign": "adwords1"});

Super Properties implementation

As we said before, Super Properties are implemented using cookies. These cookies are set to span all subdomains of your website by default, but you can turn off this feature if you want each subdomain to have a separate set of super properties.

All you have to do is set the cross_subdomain_cookie configuration parameter to false, like so:

<script type="text/javascript">
        mixpanel.set_config({ cross_subdomain_cookie: false });
</script>

Limitations:

Unfortunately Super Properties are not available for Facebook due to limitations of the platform. Super properties use cookies and thus cannot be used in FBJS. Iframe apps are affected as well as some browsers reject cookies from iframes.