Super Properties
This is an advanced guide. It assumes that you understand the concept of 'properties'.
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.
Super properties are an easy way to store data about your users. They are global properties that get attached to everything you are tracking. If you find it tedious to continuously attach a gender property of a user to every event, this is for you.
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.
Here's a breakdown of the function and its parameters. We'll show an example implementation in a moment.
mpmetrics.register(properties, type, days);
Required:
@properties: A dictionary of properties in the usual format. {"key" : "value", "key2", "value2"}
Optional:
@type: The type of event to register these properties for
"all": All data (DEFAULT)
"events": Only events
"funnels": Only funnels
@days: The number of days to store this information (DEFAULT 7)
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" src="http://mixpanel.com/site_media/js/api/mixpanel.js"></script>
<script type="text/javascript">
try {
var mpmetrics = new MixpanelLib("YOUR_TOKEN");
mpmetrics.register({"user type": "noob", "gender": "male"});
} catch(err) {}
</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() {
...
mpmetrics.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
mpmetrics.track('button click');it would actually be sent to the server as
mpmetrics.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.
mpmetrics.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.
If you want certain super properties to only show up for funnels, and not all events, just register them with the "funnels" type. Otherwise, it will default to adding them to both events and funnels.
mpmetrics.register({"ad campaign": "adwords1"}, "funnels");In this example, the 'ad campaign' super property would only be sent with funnel events.
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" src="http://mixpanel.com/site_media/js/api/mixpanel.js"></script>
<script type="text/javascript">
try {
var mpmetrics = new MixpanelLib("YOUR_TOKEN");
mpmetrics.set_config({ cross_subdomain_cookie: false });
mpmetrics.register({"user type": "noob", "gender": "male"});
} catch(err) {}
</script>
