Created
December 25, 2011 21:25
-
-
Save hughfdjackson/1519765 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 MixTracker(token) { | |
| if (token == null) throw "You forgot to enter a MixPanel token!"; | |
| this.token = token; | |
| this.mpq = []; | |
| this.mpq.push(["init", this.token]); | |
| (function () { | |
| var b, a, e, d, c; | |
| b = document.createElement("script"); | |
| b.type = "text/javascript"; | |
| b.async = true; | |
| b.src = (document.location.protocol === "https:" ? "https:" : "http:") + "//api.mixpanel.com/site_media/js/api/mixpanel.js"; | |
| a = document.getElementsByTagName("script")[0]; | |
| a.parentNode.insertBefore(b, a); | |
| e = function (f) { | |
| return function () { | |
| this.mpq.push([f].concat(Array.prototype.slice.call(arguments, 0))) | |
| } | |
| }; | |
| d = ["init", "track", "track_links", "track_forms", "register", "register_once", "identify", "name_tag", "set_config"]; | |
| for (c = 0; c < d.length; c++) { | |
| this.mpq[d[c]] = e(d[c]) | |
| } | |
| })(); | |
| this.getIP = function () { | |
| if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest(); | |
| else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); | |
| xmlhttp.open("GET", "http://api.hostip.info/get_html.php", false); | |
| xmlhttp.send(); | |
| hostipInfo = xmlhttp.responseText.split("\n"); | |
| for (i = 0; hostipInfo.length >= i; i++) { | |
| ipAddress = hostipInfo[i].split(":"); | |
| if (ipAddress[0] == "IP") return ipAddress[1]; | |
| } | |
| return false; | |
| }; | |
| this.track = function () { | |
| this.mpq.track("Success!"); | |
| var ip = this.getIP(); | |
| }; | |
| } | |
| var mpqjs = new MixTracker("c07aeed7a90edaf9a8c3cac28ca9d5e4"); | |
| mpqjs.track(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment