Skip to content

Instantly share code, notes, and snippets.

@ak--47
Last active August 16, 2024 04:05
Show Gist options
  • Save ak--47/ebbd7ec4b470b740a9c42f4c792cd409 to your computer and use it in GitHub Desktop.
Save ak--47/ebbd7ec4b470b740a9c42f4c792cd409 to your computer and use it in GitHub Desktop.
Mixpanel / Adobe: Event Model + Hit Model
/***
*
* MIXPANEL vs ADOBE ANALYTICS
* merchandising eVars and client side attribution 👎
* sending events and passing objects with properties 👍
*/
// ADOBE ANALYTICS: merchandising eVars and client side attribution
// Product View Event, attributed to internal search
s.events = "prodView";
s.products = ";productId12345;;;;eVar76=internal_search"; // Set eVar76 to "internal_search" for product "productId12345"
s.tl(true,'o','Product View'); // Send the product view event
// Add to Cart Event attributed to category page
s.events = "scAdd";
s.products = ";productId67890;1;29.99;;eVar76=category_page"; // Set eVar76 to "category_page" for product "productId67890"
s.tl(true,'o','Add to Cart'); // Send the add to cart event
// Purchase Event, attributed to event1 and event2
s.events = "purchase";
s.products = ";productId12345;1;49.99;;event1"; // Include event1 for product "productId12345"
s.products += ",;productId67890;2;59.98;;event2"; // Include event2 for product "productId67890"
s.tl(true,'o','Purchase'); // Send the purchase event
// MIXPANEL: events and properties
mixpanel.track("Product View", {
"Product ID": "12345",
"attributed to": "internal search"
});
mixpanel.track("Add to Cart", {
"Product ID": "67890",
"quantity": 1,
"price": 29.99,
"attributed to": "category page"
});
// no explicit attribution is required on the purchase
// you get to define your attribution strategy in the analysis UI
mixpanel.track("Purchase", {
"basket": [
{
"Product ID": "12345",
"quantity": 1,
"price": 49.99,
"event": "event1"
},
{
"Product ID": "67890",
"quantity": 2,
"price": 59.98,
"event": "event2"
}
]
})
// note: mParticle has a very similar (event based) API to Mixpanel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment