Assume 4 unique events (1 β 4) , each with a different distinct_id (A β D)
[{
"event": 1,
"properties": {"distinct_id": "A"}
},
{
"event": 2,| $(document).ready(function(){ | |
| //initialize everyone as an unknown user | |
| mixpanel.register({"known-user":false}); | |
| //build a list of properties to send with the page View event | |
| var pageProps = {"page name":$(document).attr('title')} | |
| //sends the page load event; a response of 1 on the XHR request means mixpanel got the data | |
| mixpanel.track('Page View', pageProps) | |
| }) |
| 04875712bf99ebf077b759b3a06b370be4929115e7eb14737e87a91bc7a7542f6647010bfb99d52c788299ff6100c61eb98b731ea05482f44a9387f3206f1e8cae;jasonseiler |
| //an example of Mixpanel implemented in a frameworkless SPA | |
| //docs: https://developer.mixpanel.com/docs/javascript | |
| //by AK | |
| const app = { | |
| init: function() { | |
| console.log("app init!"); | |
| this.cacheDOM(); | |
| this.bindEvents(); | |
| this.authUser().then((user) => { |
| //a vanilla implementation of .track() | |
| //docs: https://developer.mixpanel.com/docs/http | |
| //by AK | |
| function trackStuff(uuid, eventName, props, token) { | |
| //the mixpanel data model | |
| let spec = { | |
| "event": eventName, | |
| "properties": { | |
| // these two properties are required! |
| //PUT YOUR MIXPANEL TOKEN AND SECRET BELOW: | |
| const credentials = { | |
| "token": "your-mixpanel-token-here", | |
| "secret": "your-mixpanel-secret-here" | |
| } | |
| /* |
| #!/usr/bin/env node | |
| //https://gist.github.com/5d8697db0dffc3bb76419cabc75bd376 | |
| //vital LFO generator | |
| //points are 2x num_point | |
| //points are between 0 and 1 | |
| //powers are same as num_point | |
| //powers are between -20 and 20 | |
| /* beautify ignore:start */ |
| // written for google's app script inside google sheets | |
| // https://developers.google.com/apps-script/guides/sheets | |
| function syncLookupTable() { | |
| console.log('syncing lookup table!') | |
| //credentials | |
| const credentials = { | |
| groupKey : `{{ your group key for existing lookup table }}`, | |
| serviceAcct: `{{ service acct username }}`, |
| // GitHub to Mixpanel Annotations | |
| // by AK | |
| // ak@mixpanel.com | |
| // purpose: ingest github webhooks; create Mixpanel annotations | |
| //deps | |
| const crypto = require('crypto'); | |
| const http = require("https"); | |
| let endpoint = `https://dm3.mixpanel.org/refreshDungeon` | |
| let auth = `Bearer ${inputData.token}` | |
| let dungeon = inputData.dungeon | |
| let opts = { | |
| method: "POST", | |
| body: dungeon, | |
| headers: { | |
| "Content-Type" : "application/json", | |
| "Authorization" : auth |