Skip to content
Notifications
Clear all

TIL: You can use their API to auto-create goals.

3 Posts
3 Users
0 Reactions
1 Views
(@finops_auditor_ray)
Estimable Member
Joined: 4 months ago
Posts: 115
Topic starter   [#17495]

Alright, so the Fathom hype train is usually about the "no-code" clicky-click interface. Fine for one-offs. But if you're managing more than a handful of sites and actually care about tracking trends, manual goal creation is a time sink masquerading as simplicity.

Their API is the real unlock. You can script goal creation based on events—new site launches, new marketing campaign landing pages, whatever. This means your analytics actually keep pace with your infra, which is how it *should* work.

Here's a crude but functional Python snippet I use. It checks for a new page URL in our site deployment manifest, then creates a goal to track its visits.

```python
import requests

FATHOM_API_KEY = 'your_key_here'
SITE_ID = 'your_site_id_here'

def create_pageview_goal(page_path, goal_name):
url = "https://api.usefathom.com/v1/goals"
headers = {"Authorization": f"Bearer {FATHOM_API_KEY}"}
payload = {
"site_id": SITE_ID,
"event": "pageview",
"path": page_path,
"title": goal_name
}
response = requests.post(url, json=payload, headers=headers)
# Always log the response. Don't trust it worked.
print(f"Status: {response.status_code}, Response: {response.text}")
return response.status_code == 200

# Example: Trigger this from your CI/CD pipeline post-deploy
new_feature_page = "/launch/new-feature"
create_pageview_goal(new_feature_page, "New Feature Launch Page")
```

Key points:
* This moves goal creation from a manual, forgettable task to an automated part of your workflow.
* The API is straightforward, but like any cloud service, monitor your usage. It's another thing that can fail silently.
* You'll need to handle auth and errors properly. This example is barebones.

Now, the real test: does this actually save time and improve data consistency? In my case, yes. But I'd want to see the bill from Fathom to see if there's a cost impact for high volumes of API calls versus manual creation. Probably negligible, but I don't take claims on faith.

show me the bill


show me the bill


   
Quote
(@j_carter)
Estimable Member
Joined: 4 months ago
Posts: 113
 

That's a solid point about keeping analytics in sync with infrastructure. I've been in a similar spot, but with migration scripts triggering events in our CRM.

Have you run into any rate limiting with the Fathom API when running your script? I'm thinking of hooking something similar into our CI/CD pipeline for new landing pages.


Migration is never smooth.


   
ReplyQuote
(@danm)
Estimable Member
Joined: 1 week ago
Posts: 122
 

Good question. I haven't hit any rate limits with Fathom, but the script only fires on new deployments so it's not exactly high volume. That said, it's definitely a good candidate for CI/CD. We run it as a final step in our static site build job, so the goal exists before the page even goes live. Just make sure you're handling the API key as a secret variable, not hardcoded.



   
ReplyQuote