Skip to main content

Create a New Goal for the Experiment

Goal

Goals are metrics to track campaign success. Here, we’ll create a Click goal to count clicks on the .cta-button element. See this guide for more.

Requirements

  • access token

To use the Automation API, you first need an access token.
Follow the instructions in this section to retrieve it programmatically.

Create the Goal

Endpoint:

POST https://api.kameleoon.com/goals
NameTypeDescription
descriptionStringGoal description (e.g., "Number of CTA clicks").
nameStringGoal name (e.g., "Clicks on CTA").
siteIdStringThe project’s siteId.
paramsObjectIncludes element selectors for click tracking.

Example:

curl -L -X POST 'https://api.kameleoon.com/goals' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
--data-raw '{
"description": "Number of times CTA button was clicked",
"hasMultipleConversions": true,
"name": "Clicks on CTA",
"params": {
"customSelectors": [
{
"mode": "CUSTOM",
"selector": ".cta-button, #bloc-789"
}
]
},
"siteId": 29353,
"status": "ACTIVE",
"type": "CLICK"
}'