Skip to content

Instantly share code, notes, and snippets.

View ttrefren's full-sized avatar

Tim Trefren ttrefren

  • Oakland, CA
View GitHub Profile
function invite_friends() {
...
mpmetrics.track('invite friends', { 'num_friends': friends.length, 'id': user_id });
...
mpmetrics.track_funnel('intro skip', 2, 'invite', { 'from': source });
}
// Track a page load. Very simple.
mpmetrics.track("Page load");
// Track a user that plays a game. We include the genre and game title.
mpmetrics.track('Play game', {'genre': 'action', 'title': 'Tomb Raider'});
// Track the first step of a signup funnel.
mpmetrics.track_funnel("Signup", 1, "Hit landing page", {'from': 'google'});
// Register some properties to include with all events sent, so you don't have
// import the library - this will change based on where you put it
import MixpanelLib;
// initialize with your project token
internal var mpmetrics:MixpanelLib = new MixpanelLib("YOUR TOKEN");
// track events with ease
private function sendPhoto():void {
// Do stuff
mpmetrics.track("Sent photo", {'type': 'png'});
<script type="text/javascript">
var mp_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + mp_protocol + "api.mixpanel.com/site_media/js/api/mixpanel.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<a href="http://mixpanel.com">
<img src="http://mixpanel.com/site_media/images/mixpanel_partner_logo.gif"
alt="Analytics by Mixpanel" />
</a>
if(!UserVoice){var UserVoice={};}
if(!UserVoice.Util){UserVoice.Util={sslAssetHost:"https://uservoice.com",assetHost:"http://cdn.uservoice.com",getAssetHost:function(){return("https:"==document.location.protocol)?this.sslAssetHost:this.assetHost;},render:function(template,params){return template.replace(/\#{([^{}]*)}/g,function(a,b){var r=params[b];return typeof r==='string'||typeof r==='number'?r:a;})},toQueryString:function(params){var pairs=[];for(key in params){if(params[key]!=null&&params[key]!=''){pairs.push([key,params[key]].join('='));}}
return pairs.join('&');}}}
UserVoice.Page={getDimensions:function(){var de=document.documentElement;var width=window.innerWidth||self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;var height=window.innerHeight||self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;return{width:width,height:height};}}
UserVoice.Dialog={preload:function(id_or_html){if(!this.preloaded){var element=document.getElementById(id_or_html);var html=(element==null)?id
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
var mp_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + mp_protocol + "api.mixpanel.com/site_media/js/api/mixpanel.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
<script type="text/javascript" src="http://api.mixpanel.com/site_media/js/api/mixpanel.js"></script>
<script type="text/javascript">
try {
var mpmetrics = new MixpanelLib("YOUR TOKEN");
} catch(err) {
null_fn = function () {};
var mpmetrics = { track: null_fn, track_funnel: null_fn, register: null_fn, register_once: null_fn };
}
</script>
...
<!-- First include the script: -->
<script type="text/javascript">
var mp_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + mp_protocol + "api.mixpanel.com/site_media/js/api/mixpanel.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<!-- Initialize it with your project token -->
<script type="text/javascript">
try {
var mpmetrics = new MixpanelLib("YOUR_TOKEN");
mpmetrics.register({"ad campaign": "adwords1"}, "funnels");