plausible / plausible-tracker

Frontend library to interact with Plausible Analytics
https://github.com/plausible/plausible-tracker
MIT License
214 stars 46 forks source link

[Feature Request] programmatically set Goals #44

Closed chulinguy closed 2 years ago

chulinguy commented 2 years ago

Detailed Description

Right now the only way to enter goals is via the admin UI. Would it be possible to implement one of these programmatic way to set goals:

  1. I can fire an event from my app with a custom goal that's not set up, and Plausible would simply create a new goal (GA does this)
  2. we expand the Plausible API so developers can add or remove goals programmatically (probably some kind of oAuth / token would be needed for this)

Context

We are tracking sets of activities by state. The client insists on having the state name in the goals, ie: Georgia Activity. I'd have to manually add / remove goals for 50 states, and if I enter a typo in the state name, then events for that state would be lost forever.

metmarkosaric commented 2 years ago

thanks for the feedback @chulinguy! it's already possible to create and delete goals using our sites API. see https://plausible.io/docs/sites-api

chulinguy commented 2 years ago

I think it's not a common practice to use a PUT route such /api/v1/sites/goals as to do read and create, no ?

chulinguy commented 2 years ago

@metmarkosaric wait but we can only generate API tokens for the Stats API, and we need an API token for the site API to hit /api/v1/sites/goals ???

metmarkosaric commented 2 years ago

hi @chulinguy! please contact us to get a sites API key