summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorraylu <raylu@mixpanel.com>2012-10-26 00:55:43 -0700
committerraylu <raylu@mixpanel.com>2012-10-26 00:55:43 -0700
commit77e2a0ffef69cd5b55cf7d9b40b2d0ed258dcf0a (patch)
tree36b8cbc6dca6a148d6181b60355924aa96027b35
parent6b490faf136fedaee9759a1b6164a90dcdb0f408 (diff)
downloadpathery-77e2a0ffef69cd5b55cf7d9b40b2d0ed258dcf0a.tar.xz
integrate mixpanel people
https://mixpanel.com/docs/people-analytics
-rw-r--r--globe.php8
-rw-r--r--includes/header.php19
-rw-r--r--pages/about.php2
-rw-r--r--pages/login.php7
4 files changed, 26 insertions, 10 deletions
diff --git a/globe.php b/globe.php
index 05d2e39..c901175 100644
--- a/globe.php
+++ b/globe.php
@@ -27,7 +27,7 @@ function CookieLogin() {
$userID = $_COOKIE['userID'];
$auth = $_COOKIE['auth'];
- $sql = "SELECT `openID`, `displayName`, `isAdmin`
+ $sql = "SELECT `openID`, `email`, `displayName`, `dateJoined`, `isAdmin`
FROM `users`
WHERE `ID` = '$userID'
";
@@ -36,7 +36,7 @@ function CookieLogin() {
if (mysql_num_rows($result) == 0)
return;
- list($claimedid, $display, $isAdmin) = mysql_fetch_row($result);
+ list($claimedid, $email, $display, $dateJoined, $isAdmin) = mysql_fetch_row($result);
//I last-see you now!
$sql = "UPDATE `users`
@@ -56,7 +56,9 @@ function CookieLogin() {
$_SESSION['accepted'] = 1;
$accepted = 1;
$_SESSION['userID'] = $userID;
+ $_SESSION['email'] = $email;
$_SESSION['displayName'] = $display;
+ $_SESSION['dateJoined'] = $dateJoined;
if ($isAdmin == 1)
$_SESSION['isAdmin'] = true;
@@ -189,4 +191,4 @@ function EmailError($data, $subject = "Pathery Error Report") {
Return $mail_sent;
}
-?> \ No newline at end of file
+?>
diff --git a/includes/header.php b/includes/header.php
index f9b0f18..d59699f 100644
--- a/includes/header.php
+++ b/includes/header.php
@@ -24,16 +24,18 @@ function htmlHeader($css = array(), $title = 'Pathery', $desc = '', $scripts = a
<script src="js/ajax.js?v=1" async="async"></script>
<script src="js/mapspecs.js?v=1"></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,[]);
+ <script>
+ (function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.1.min.js';d=c.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==typeof f?
+ g=a[f]=[]:f="mixpanel";g.people=g.people||[];h="disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.identify people.set people.increment".split(" ");for(e=0;e<h.length;e++)d(g,h[e]);a._i.push([b,c,f])};a.__SV=1.1})(document,window.mixpanel||[]);
mixpanel.init("24743c6567f831ddfcbbbd3f397e11e4");
<?php
if ($accepted) {
if ($_SESSION['displayName'] != 'noname')
echo 'mixpanel.name_tag(' . json_encode($_SESSION['displayName']) . ');';
- if ($_SERVER['HTTP_HOST'] == 'www.pathery.com')
+ if ($_SERVER['HTTP_HOST'] == 'www.pathery.com') {
echo 'mixpanel.identify(' . json_encode($_SESSION['userID']) . ');';
+ echo 'mixpanel.people.identify(' . json_encode($_SESSION['userID']) . ');';
+ }
}
?>
</script>
@@ -94,6 +96,15 @@ function htmlFooter() {
ga.async = true;
ga.src = ('https:' == proto ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
s.parentNode.appendChild(ga, s);
+
+<?
+ echo "mixpanel.people.set({
+ \$email: " . json_encode($_SESSION['email']) . ",
+ \$username: " . json_encode($_SESSION['displayName']) . ",
+ \$last_login: '" . date(DateTime::ISO8601) . "',
+ \$created: '" . $_SESSION['dateJoined'] . "'
+ });";
+?>
})();
</script>
diff --git a/pages/about.php b/pages/about.php
index 3276f0f..f458f49 100644
--- a/pages/about.php
+++ b/pages/about.php
@@ -61,7 +61,7 @@ topbar($Links);
<h3>Other Mentions:</h3>
Mixpanel has been friendly and helpful:
<br />
-<a href='https://mixpanel.com/f/partner'><img src='https://mixpanel.com/site_media/images/partner/badge_blue.png' alt='Mobile Analytics' /></a>
+ <a href="https://mixpanel.com/f/partner"><img src="//cdn.mxpnl.com/site_media/images/partner/badge_blue.png" alt="Mobile Analytics" /></a>
</div>
<br />
diff --git a/pages/login.php b/pages/login.php
index 5042cd8..b8662ab 100644
--- a/pages/login.php
+++ b/pages/login.php
@@ -50,7 +50,7 @@ try {
//* Modify this to WHERE `email`
//$sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName` FROM `users` WHERE `email` = '$email'";
//$sql = "SELECT `ID`, `isAdmin` FROM `users` WHERE `openID` = '$claimedid'";
- $sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName` FROM `users` WHERE `openID` = '$claimedid' OR `email` = '$email'";
+ $sql = "SELECT `ID`, `isAdmin`, `openID`, `displayName`, `dateJoined` FROM `users` WHERE `openID` = '$claimedid' OR `email` = '$email'";
$result = mysql_query($sql);
$_SESSION['isAdmin'] = false;
@@ -62,8 +62,8 @@ try {
if (mysql_result($result, 0, 'isAdmin') == 1)
$_SESSION['isAdmin'] = true;
- //Use the displayname we have on record.
$display = mysql_result($result, 0, 'displayName');
+ $dateJoined = mysql_result($result, 0, 'dateJoined');
// <DEBUG>
//Multiple accounts found?
@@ -115,6 +115,7 @@ try {
//echo "$sql <br /> <br />";
if ($result) {
$userID = mysql_insert_id();
+ $dateJoined = date(DateTime::ISO8601);
} //Oh crap?
else {
$errortext = "<br />new-user db register failure of unknown cause.\n
@@ -134,7 +135,9 @@ try {
//$_SESSION['Passcode'] = MD5($Password.$Pepper.$Username);
$_SESSION['accepted'] = 1;
$_SESSION['userID'] = $userID;
+ $_SESSION['email'] = $email;
$_SESSION['displayName'] = $display;
+ $_SESSION['dateJoined'] = $dateJoined;
//The below is me hashing the claimedID.
$salt = "33qs5d4j6z98gt1a7n6b5d4x1c66f5nuh8a6d8g9j09aphgf56z5745";