diff options
author | raylu <raylu@mixpanel.com> | 2012-04-25 23:19:52 -0700 |
---|---|---|
committer | raylu <raylu@mixpanel.com> | 2012-04-25 23:19:52 -0700 |
commit | df71da70062b9f70d9906fa7df7350d47be79acc (patch) | |
tree | c6deaaa183640703fefb5068e02c7a2aa96aec68 | |
parent | c8783d4dc257913ba527d469c88d7b97770be3de (diff) | |
download | pathery-df71da70062b9f70d9906fa7df7350d47be79acc.tar.xz |
add tutorial and map difficulty tracking
-rw-r--r-- | includes/header.php | 26 | ||||
-rw-r--r-- | js/mapspecs.js | 11 | ||||
-rw-r--r-- | pages/home.php | 8 | ||||
-rw-r--r-- | pages/tutorial.php | 3 |
4 files changed, 26 insertions, 22 deletions
diff --git a/includes/header.php b/includes/header.php index 3f83530..a1dbfa4 100644 --- a/includes/header.php +++ b/includes/header.php @@ -19,6 +19,20 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '') { ?>
<script src="js/ajax.js" async="async"></script>
<script src="js/mapspecs.js"></script>
+
+ <script>
+ (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:")+'//api.mixpanel.com/site_media/js/api/mixpanel.2.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_pageview track_links track_forms register register_once unregister identify name_tag set_config".split(" ");
+ 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("24743c6567f831ddfcbbbd3f397e11e4");
+<?php
+ if ($_SESSION['accepted'] == 1) {
+ if ($_SESSION['displayName'] != 'noname')
+ echo 'mixpanel.name_tag(' . json_encode($_SESSION['displayName']) . ');';
+ if ($_SERVER['HTTP_HOST'] == 'www.pathery.com')
+ echo 'mixpanel.identify(' . json_encode($_SESSION['userID']) . ');';
+ }
+?>
+ </script>
</head>
<?php
}
@@ -53,18 +67,6 @@ function htmlFooter() { ga.src = ('https:' == proto ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
s.parentNode.appendChild(ga, s);
})();
-
- (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:")+'//api.mixpanel.com/site_media/js/api/mixpanel.2.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_pageview track_links track_forms register register_once unregister identify name_tag set_config".split(" ");
- 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("24743c6567f831ddfcbbbd3f397e11e4");
- <?php
- if ($_SESSION['accepted'] == 1) {
- if ($_SESSION['displayName'] != 'noname')
- echo 'mixpanel.name_tag(' . json_encode($_SESSION['displayName']) . ');';
- if ($_SERVER['HTTP_HOST'] == 'www.pathery.com')
- echo 'mixpanel.identify(' . json_encode($_SESSION['userID']) . ');';
- }
- ?>
</script>
</body>
diff --git a/js/mapspecs.js b/js/mapspecs.js index c767db7..662d47c 100644 --- a/js/mapspecs.js +++ b/js/mapspecs.js @@ -31,7 +31,7 @@ var htmlscores = ''; var htmlnotification = '';
var jsonmapdata = new Object;
//var jsonmapdata.solutions = new Array();
-
+var mapType; // 1 = simple, 2 = normal, ...; used for mixpanel tracking
// function loadAllSolutions() {
// for(var i in jsonmapdata.solutions) {
@@ -206,7 +206,8 @@ function doSend(mapid) { mixpanel.track('click go', {
'speed': speed,
'mute': mute,
- 'mapid': mapid
+ 'mapid': mapid,
+ 'type': mapType
});
}
@@ -300,14 +301,15 @@ function request_path_done() { }
// Force score update.
-function updateScoresReq(mapid) {
+function updateScoresReq(mapid, type) {
//Get score update.
ajax.requestFile = "do.php?checkachieve=true&r=getscores&mapid="+mapid; //prepare strdata
ajax.onCompletion = updateScoresGet; // Specify function to be executed on response.
ajax.runAJAX();// Do it!
+ mapType = type;
}
function updateScoresGet() {
- JO = decryptJSON(ajax.response);
+ var JO = decryptJSON(ajax.response);
updateDsp(JO.mapid, 'dspScore', JO.scores);
}
@@ -764,4 +766,3 @@ function minmap(obj) { setTimeout("de = false;", 1000);
}
//== End
-
diff --git a/pages/home.php b/pages/home.php index 71bcd33..45911c5 100644 --- a/pages/home.php +++ b/pages/home.php @@ -152,7 +152,7 @@ function displayMaze($motd, $mapType) { //data for the topscores
$topscores = topScores($motd['id'], 30);
- $topscorediv = "<center><a href='javascript:updateScoresReq($mapID);'>Update</a></center> <div id='$mapID,dspScore'>\n$topscores\n</div>";
+ $topscorediv = "<div id='$mapID,dspScore'>\n$topscores\n</div>";
$userID = $_SESSION['userID'];
if ($_SESSION['accepted'] == 1) {
@@ -266,10 +266,10 @@ function showStats(type) { elem.className += 'selected';
var x = 0;
- for(var mapid in jsonmapdata) {
+ for(var mapid in jsonmapdata) {
x++;
if (x == type)
- updateScoresReq(mapid);
+ updateScoresReq(mapid, type);
}
}
showStats(1);
@@ -281,4 +281,4 @@ showStats(1); <?php
htmlFooter();
-?>
\ No newline at end of file +?>
diff --git a/pages/tutorial.php b/pages/tutorial.php index ed4aa9e..7830ef4 100644 --- a/pages/tutorial.php +++ b/pages/tutorial.php @@ -202,6 +202,7 @@ function TutorialView(low, high) { this.nextbtn = document.getElementById('nextbtn');
this.prevbtn = document.getElementById('prevbtn');
this.interval1 = this.interval2 = null;
+ mixpanel.track('tutorial', {'step': this.cur});
}
TutorialView.prototype.showTutorial = function(num) {
for (var i = this.low; i <= this.high; i++) {
@@ -232,6 +233,7 @@ TutorialView.prototype.next = function() { //this.nextbtn.className += ' disabled';
}
this.prevbtn.className = this.prevbtn.className.replace(' hidden', '');
+ mixpanel.track('tutorial', {'step': this.cur});
}
TutorialView.prototype.prev = function() {
this.showTutorial(--this.cur);
@@ -257,7 +259,6 @@ TutorialView.prototype.unlock = function(n) { }, 600);
}
}
-
}
</script>
|