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 / productSchool.js
Last active May 19, 2026 13:05
πŸ’Ύ 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 / reload-mp.sh
Last active August 4, 2025 14:18
reload mixpanel data
# reload all EVENTS from one project to another
# environment variables
# CUSTOMIZE THESE πŸ‘‡
export START=2023-01-01
export END=2023-05-31
export SOURCE_SECRET=my-source-project-secret
export TARGET_SECRET=my-target-project-secret
# export β†’ import
@ak--47
ak--47 / adobe-hits.md
Last active July 28, 2025 16:03
Mixpanel + Adobe Data Model Comparisons
graph TD;

    %% ---- Adobe Brand Colors (Enhanced Contrast) ----
    classDef userAction fill:#f8f8f8,stroke:#2D2E2D,color:#2D2E2D,stroke-width:2px;
    classDef serverCall fill:#666,stroke:#2D2E2D,color:#fff,stroke-width:2px;
    classDef hitPacket fill:#ED2224,stroke:#fff,color:#fff,stroke-width:3px;
    classDef warehouse fill:#2D2E2D,stroke:#ED2224,color:#f9f9f9,stroke-width:2px;
    classDef painful fill:#8B0000,stroke:#ED2224,color:#fff,stroke-width:3px;
    classDef titleBg fill:#1a1a1a,stroke:#ED2224,color:#f9f9f9;
@ak--47
ak--47 / mixpanel-heartbeat.js
Created June 11, 2025 20:08
Mixpanel Heartbeat API
/**
* @fileoverview Mixpanel Heartbeat API Extension
*
* Augments Mixpanel SDK with heartbeat() functionality for event aggregation.
* Useful for tracking continuous activities like video/audio playback, reading progress, etc...
* This API aggregates small events into summary events before sending to Mixpanel
*
* @author AK: ak@mixpanel.com
* @version 1.0.1
*/
@ak--47
ak--47 / event_data.xml
Created February 6, 2025 16:01
an XML file
<?xml version="1.0" encoding="UTF-8"?>
<events>
<event>
<timestamp>2025-02-06T12:34:56Z</timestamp>
<user_id>12345</user_id>
<event_id>c1d2e3f4-5678-9101-1121-314151617181</event_id>
<event_type>click</event_type>
<page_url>https://example.com/home</page_url>
<duration>5.3</duration>
<is_logged_in>true</is_logged_in>
@ak--47
ak--47 / event_data.csv
Last active February 6, 2025 15:51
a CSV file
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 16 columns, instead of 7 in line 5.
event_id,timestamp,user_id,event_type,page_url,time_spent_seconds,is_mobile,referrer,click_coordinates,items_in_cart,user_agent,browser_language,is_ad_blocker_enabled,favorite_colors,notes,is_conversion
1,2023-10-01T12:34:56Z,101,page_view,https://example.com/home,45,TRUE,https://google.com,"-1,024,768",3,Mozilla/5.0 (Windows NT 10.0; Win64; x64),en-US,TRUE,"blue,green",User loves cats.,FALSE
2,2023-10-01T12:35:10Z,102,click,https://example.com/products,10,FALSE,https://bing.com,"-800,600",,Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7),en-GB,FALSE,"red,orange",,TRUE
3,2023-10-01T12:36:22Z,103,add_to_cart,https://example.com/product/123,30,TRUE,https://yahoo.com,"-12,801,024",1,Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X),fr-FR,TRUE,"purple,yellow",User left a funny comment.,FALSE
4,2023-10-01T12:37:45Z,104,page_view,https://example.com/about,120,FALSE,,,,Mozilla/5.0 (Linux; Android 10; SM-G975F),de-DE,FALSE,"black,white",,FALSE
5,2023-10-01T12:38:50Z,105,purchase,https://example.com/checkout,60,TR
@ak--47
ak--47 / candivore.md.md
Created November 26, 2024 15:01
candivore.md

Candivore: POC + Path Forward

Snowplow's Schema

Snowplow is a state-of-the-art data collection platform which advocates for self-describing-objects. This means that events (rows) that travel through Snowplow's pipeline have a highly nested and hierarchical structure:

{
  "event": "user_transaction",
  "time": 1730592005,
  "APP_ID": "Match-Masters",
@ak--47
ak--47 / example.json
Created November 14, 2024 14:48
weird duckDb unnesting thing
{"origRow": 1, "foo":42,"bar":"fortyTwo","myNest":[{"hello":"space","goodbye":"world"},{"hello":"time","goodbye":"gravity"}]}
{"origRow": 2, "foo":420,"bar":"fortyTwenty","myNest":[{"hello":"you","goodbye":"me"},{"hello":"we","goodbye":"thee"}]}
@ak--47
ak--47 / gtmMixpanelAutoCapture.md
Last active November 6, 2024 03:26
GA4 / UA β†’ Mixpanel (event fowarding)

Fowarding GA4 Events to Mixpanel via GTM

essentially: bind mixpanel.track() calls to existing Universal Analytics + GA4 implementations without adding new triggers for each event

note: this is experimental... every product's GTM implementation is different... please test this in a sandbox before using in production

Step 1: Install the Mixpanel GTM Template to your GTM container


this module binds all of mixpanel's javascript SDK methods to an object that is native to the GTM container.

@ak--47
ak--47 / mp_azure_snowflake.sql
Last active October 15, 2024 13:32
MIXPANEL β†’ AZURE β†’ SNOWFLAKE pipeline
-- MIXPANEL β†’ AZURE β†’ SNOWFLAKE pipeline
-- the second half...
-- by ak@mixpanel.com
-- docs: https://docs.snowflake.com/en/user-guide/data-load-azure-create-stage
-- create storage integration
CREATE OR REPLACE STORAGE INTEGRATION azure_intergration
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = AZURE
ENABLED = TRUE