Skip to content

Instantly share code, notes, and snippets.

View ak--47's full-sized avatar

AK ak--47

View GitHub Profile
@ak--47
ak--47 / mixpanel.js
Last active August 4, 2016 22:54
Ximble: client side mixpanel tracking (example)
$(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
@ak--47
ak--47 / exampleSPAimplementations.js
Last active July 19, 2020 14:06
An Example of Mixpanel inside a SPA
//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) => {
@ak--47
ak--47 / vanillaTrackStuff.js
Created July 19, 2020 14:12
Mixpanel .track() with no dependencies
//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!
@ak--47
ak--47 / productSchool.js
Last active November 9, 2024 08:10
💾 data loader for the Product Analytics Certification
//PUT YOUR MIXPANEL TOKEN AND SECRET BELOW:
const credentials = {
"token": "your-mixpanel-token-here",
"secret": "your-mixpanel-secret-here"
}
/*
@ak--47
ak--47 / vitalLfoGen.js
Last active June 3, 2021 03:37
Create LFOs for Vital... put them on the clipboard
#!/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 */
@ak--47
ak--47 / gsheetToMixpanelLookupTable.js
Created October 28, 2021 17:08
Google Sheets to Mixpanel (lookup table)
// 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 }}`,
@ak--47
ak--47 / githubWebhooksToMixpanelAnnotations.js
Last active February 19, 2022 16:13
Github Webhooks => Mixpanel Annotations
// GitHub to Mixpanel Annotations
// by AK
// [email protected]
// purpose: ingest github webhooks; create Mixpanel annotations
//deps
const crypto = require('crypto');
const http = require("https");
@ak--47
ak--47 / fireAndForget.js
Created March 9, 2022 14:45
fire and forget with zapier?
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
@ak--47
ak--47 / $merge.md
Last active July 10, 2022 02:45
mixpanel $merge in a nutshell

$merge in 5 mins

Assume 4 unique events (1 → 4) , each with a different distinct_id (A → D)

[{
     "event": 1,
     "properties": {"distinct_id": "A"} 
 },
 {
     "event": 2,