This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onYouTubePlayerReady(playerId) { | |
ytplayer = document.getElementById("myytplayer"); | |
ytplayer.addEventListener("onStateChange", "onytplayerStateChange"); | |
} | |
function onytplayerStateChange(newState) { | |
ytplayer = document.getElementById("myytplayer"); | |
var props = {}; | |
props['duration'] = ytplayer.getDuration(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run argv | |
tell application "iTerm" | |
activate | |
global hostname | |
set hostname to "dev" | |
if length of argv is 1 then | |
set hostname to item 1 of argv | |
end if | |
set term to (make new terminal) | |
tell term |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Plain Javascript - only works for a single item per page | |
window.onload = function() { | |
mpmetrics.track("Page view", { 'page': document.location }); | |
} | |
// Or in jQuery (much nicer) | |
$(document).ready(function() { | |
mpmetrics.track("Page view", { 'page': document.location }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<!-- The rest of your HTML code here --> | |
<input type="button" onclick="mpmetrics.track('play-song', {'genre':'rap', 'artist':'eminem'});"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://api.mixpanel.com/site_media/js/api/mpmetrics.js"></script> | |
<script type="text/javascript"> | |
try { mpmetrics.init("YOUR_TOKEN");} catch(err) {} | |
</script> | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<!-- The rest of your HTML code here --> | |
<input type="button" onclick="mpmetrics.track('game-start', {'level':'castle', 'char':'knight'})"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
your_function = function(url, data) { | |
mpmetrics.track('battle', {'spell':'fireball', 'damage':'237'}); | |
if (url) { | |
some = more_random_js; | |
} else { | |
even += "more"; | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This isn't perfect for high traffic sites, if you need something more production ready | |
# please tell us or stay tuned as we will open it up shortly. | |
import subprocess | |
import base64 | |
import simplejson | |
def track(event, properties=None): | |
""" | |
A simple function for asynchronously logging to the mixpanel.com API. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'base64' | |
require 'json' | |
require 'active_support' | |
# Adapted from the Python code here: http://mixpanel.com/api/docs/code/ | |
class MixPanel | |
# A simple function for asynchronously logging to the mixpanel.com API. | |
# This function requires `curl`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://mixpanel.com/site_media/js/api/mpmetrics.js"></script> | |
<script type="text/javascript"> | |
try { | |
mpmetrics.init("YOUR_TOKEN"); | |
mpmetrics.register({"user type": "noob", "gender": "male"}); | |
} catch(err) {} | |
</script> |
OlderNewer