Tracking Analytics
Learn how to begin tracking analytic events
Track
Once you're set up, tracking events is easy as 🥧:
Plaudy.track("purchase", {
"amount": 413.25,
"upsell": 63.25,
"referrer": "landing page",
"items": [
"dehydrated h20",
"non-gmo water",
"filtered dirt"
],
"user_id": `USER_ID` // if you didn't pass this in when using .identify()
"object_id": `OBJECT_ID` // if you didn't pass this in when using .identify()
// anything else
});
The first argument is the event_type
, which you can call whatever you'd like. The second argument is any data you want to pass in (up to 1,000 key-value pairs).
Examples
1. Tracking A Page View
Here's a simple example of everything together in a file we'll call index.js
. We'll be tracking a single page view:
import Plaudy from 'plaudy';
Plaudy.init(`YOUR_API_KEY`);
Plaudy.identify(`USER_ID`, `OBJECT_ID`);
Plaudy.track("page view", {
"title": window.location.hostname,
"url": "https://docs.plaudy.com"
});
That's it! You successfully tracked your first page view for this user! But there's so much more you can do! Keep it going! 🎉
Last updated
Was this helpful?