Get a goal
Retrieve one goal and its type-specific conversion rule.
Use clics.goals.getGoal when you need the exact configured rule before showing or changing a goal.
What you need
| Field | Required | Description |
|---|---|---|
goalId |
Yes | ID returned by createGoal or listGoals |
Example
const goal = await clics.goals.getGoal({ goalId: "goal_xxx" });
console.log(goal.displayName, goal.goalType, goal.rule);
What it returns
The returned goal contains id, projectId, displayName, envId, goalType, and rule. Treat goalType as a discriminant for rule:
{ goalType: "page", rule: { pagePath: "/pricing" } }
{ goalType: "event", rule: { eventName: "trial_started" } }
{ goalType: "outbound", rule: { outboundUrl: "https://partner.example" } }
{ goalType: "scroll_depth", rule: { pagePath: "/article", scrollDepthThreshold: 75 } }
The outboundUrl is the destination URL tracked by Clics. A scroll-depth threshold is a whole percentage from 1 to 100.
| Field | Type | Description |
|---|---|---|
id |
string |
Stable goal ID |
projectId |
string |
Parent project ID |
envId |
"production" | "development" |
Goal environment |
displayName |
string |
Label shown in Dashboard |
goalType |
Goal type | Selects the returned rule shape |
rule |
Type-specific object | Exact conversion condition, as shown above |
Errors
The method rejects with 401 for an invalid API key, 403 when the workspace cannot access the goal, and 404 when the goal does not exist.
API reference
See Get a goal for the complete schema and status codes.