Skip to content
Clics privacy-friendly cookieless web analytics documentation
Esc
navigateopen⌘Jpreview
On this page

Update a conversion goal with the Clics TypeScript SDK

Copy page

Update a goal

Update a conversion goal with the Clics TypeScript SDK when paths, event names, or labels change.

Updates an existing goal. This is a partial update: send only the fields that need to change.

Use it to rename a goal, change one rule value, or switch its type. A goal keeps its environment; envId cannot be changed after creation.

Parameters

Field Required Description
goalId Yes Goal to update
body.displayName No New label shown in Dashboard
body.goalType No New type: page, event, outbound, or scroll_depth
body.rule No Partial rule update; use camelCase fields: pagePath, eventName, outboundUrl, scrollDepthThreshold

When switching goalType, provide a complete matching rule in the same call. For example, switching to scroll_depth requires both pagePath and scrollDepthThreshold.

Signature

clics.goals.updateGoal(request, options?)

Example

import { Clics } from "@clicsdev/sdk";

const clics = new Clics({
  apiKey: process.env.CLICS_API_KEY!,
});

const result = await clics.goals.updateGoal({
  goalId: "goal_xxx",
  body: {
    displayName: "Read the guide",
  },
});

Change a scroll-depth threshold without changing the page:

await clics.goals.updateGoal({
  goalId: "goal_xxx",
  body: {
    rule: { scrollDepthThreshold: 90 },
  },
});

Switch an event goal to an outbound goal:

await clics.goals.updateGoal({
  goalId: "goal_xxx",
  body: {
    goalType: "outbound",
    rule: { outboundUrl: "https://partner.example/join" },
  },
});

What it returns

The complete goal after the update. rule is always the complete, resulting rule, even if you only sent one field in a same-type partial update.

Field Type Description
id string Stable goal ID
projectId string Parent project ID
envId "production" | "development" Original goal environment; it cannot change here
displayName string Current label shown in Dashboard
goalType Goal type Current type after the update
rule Type-specific object Complete current rule: page path, event name, outbound URL, or scroll-depth configuration

Notes

  • If body.rule is omitted, the current rule is preserved.
  • If a rule field is supplied, it must be valid for the resulting goal type.
  • Existing analytics are not rewritten; future calculation uses the updated definition.

API reference

See Update a goal for request and response schemas, status codes, and error types.

Was this page helpful?