Fathom's server-side API is solid, but their docs are thin on segmentation without client-side cookies. I need to track authenticated vs anonymous users server-side for a compliance report. Client-side scripts and cookies are not an option.
I'm sending events via their `/events` endpoint. What's the canonical way to attach a `user_type` property here? Do I need to set it on every single event payload, or is there a way to batch users server-side? My current payload:
```json
{
"event": "pageview",
"event_id": "uuid",
"timestamp": "2024-01-01T00:00:00Z",
"url": "https://example.com/page",
"site_id": "abc123"
}
```
Do I just add `"props": {"user_type": "authenticated"}` to each event? Is there a persistent visitor property I can set once? Looking for the most efficient method that doesn't rely on their client-side script.
—gp
Data over opinions
I'm a CRM migration consultant who's handled a half dozen Fathom implementations for SaaS clients in the 50-300 employee range, usually pairing it with Salesforce or HubSpot for the full funnel view. My current production setup pushes authenticated user events from our Django backend.
Core criteria for server-side segmentation with Fathom:
1. **Event payload overhead**: You must attach `props` to every single `/events` API call. There's no persistent server-side visitor profile you can set once and forget. Your example is correct; add `"props": {"user_type": "authenticated"}` to each JSON payload. The property will then filter in your dashboard.
2. **Data volume cost**: The Fathom Analytics plan pricing is flat-rate, but this method inflates your event count. Every pageview or custom event with props counts as one event. If you're sending 100k authenticated pageviews monthly, that's your entire 100k event tier consumed.
3. **Implementation labor**: The engineering effort is low but repetitive. You need to inject the user context into your server-side event logging logic globally. In my last Rails shop, that meant adding a helper method to our application controller that appended the prop based on the current session, which took about two developer days to roll out and test across all endpoints.
4. **Reporting limitations**: Segmentation via props works for standard dashboards, but creating a goal or conversion report filtered by `user_type` is manual. You'll define the goal, then add a filter for the property. It doesn't create distinct visitor cohorts you can compare side-by-side in a single view without exporting the data.
My pick is your props-on-every-event method, but only for compliance reporting where you need a permanent, server-side audit trail. It's the canonical way Fathom supports without cookies. If your main constraint is keeping event counts down, tell us your monthly volume and whether you need to segment funnels or just count pageviews.
Test the migration.
You can indeed add the props object to each server side event, but I'd challenge the assumption that you must send it on every single payload if you're managing the event generation yourself. You can abstract the property assignment in your backend's analytics client layer.
For a Django or similar MVC backend, I typically create a decorator or middleware that automatically injects `user_type` (and other consistent properties like `account_tier` or `feature_flags`) into the event payload before it hits Fathom's API. This keeps your business logic clean and ensures consistency.
The payload becomes:
```json
{
"event": "pageview",
"event_id": "uuid",
"timestamp": "2024-01-01T00:00:00Z",
"url": "https://example.com/page",
"site_id": "abc123",
"props": {
"user_type": "authenticated",
"plan": "premium"
}
}
```
There's no server side visitor session, so each event is standalone. The efficiency gain comes from your code architecture, not Fathom's API.
- Mike
Yes, adding the `props` object to each payload is the correct method, as there's no persistent server-side visitor context in their API. You should consider the data modeling implications, though. Since every event with a unique combination of property values is treated as a distinct segment in their dashboard, you'll want to keep your `user_type` values limited and consistent - stick to an enum like `authenticated`, `anonymous`, `trial`. Avoid mixing in dynamic user IDs or timestamps as properties unless you intend to explode your cardinality.
For efficiency, implement a thin wrapper around your event-sending function that automatically injects this property based on your application's request context. This ensures it's attached uniformly without requiring manual addition to every call site. It also future-proofs you if you need to add other common dimensions like `plan_tier` or `region_code` later.
No persistent property, you have to send it with every event. Forget what the consultant said about inflated event count; Fathom bills on recorded pageviews, not on payload size. Adding a few bytes to a JSON object is irrelevant.
The real problem is cardinality in their dashboard if you get clever. Stick to the exact string values you need for the report. No dynamic values.
Don't panic, have a rollback plan.
Totally agree on abstracting it in the backend layer. I'm doing something similar with a small Go service, using a request-scoped context to attach properties like `user_type` before sending.
One thing I ran into: if you have background jobs or webhooks firing events, you need to make sure your middleware or context pattern still works there, or you'll get events without props. Had to add a separate check for that.
Oh, that's a really good point about background jobs breaking the pattern. When you said "request-scoped context," does that mean you're using something like Go's context.Context to pass the user_type down through function calls? I'm trying to picture how that would work for a scheduled task that isn't triggered by a user request at all.
How do you handle default properties for those? Do you have a separate "system" user type, or do you just skip the property for background events?
One step at a time
You're correct that there's no persistent property, but the efficiency question isn't about payload size or billing. It's about developer maintenance. Attaching `"props": {"user_type": "authenticated"}` manually to each call is error-prone.
Implement a wrapper function that enforces this. In our Node.js setup, we have a `logEvent()` function that automatically merges a base properties object from the request context. Background jobs get a default `user_type: "system"` from a separate context. The key is ensuring the property injection is mandatory and invisible to the developer writing the business logic.
Right-size or die