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
your_function = function(url, data) { | |
mpmetrics.track('play-game', {'level':'12', 'weapon':'sword', 'character':'knight'}); | |
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
... | |
<!-- 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
<a href="javascript:void(0);" onclick="mpmetrics.track('click menu', {'menu item': 'about'}, | |
function() { window.location = 'http://yoursite.com'; });"> |
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/mptfb.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
# cURL example | |
import path.to.logger as mpmetrics | |
... | |
def some_function(args): | |
mpmetrics.track("purchase", {"type": "Easter", "item_number": "3123", "ip": "123.78.98.34"}) | |
... | |
# Now your regular function code | |
... |
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
<?php | |
# cURL example | |
require_once('path/to/logger.php'); | |
$metrics = new MetricsTracker("YOUR_TOKEN"); | |
... | |
function some_function($args) { | |
$metrics->track('menu_click', array('button'=>'learn more', | |
'color'=>'green', | |
'ip'=>$_SERVER['REMOTE_ADDR']) | |
); |
OlderNewer