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
Name | Type | Description |
---|---|---|
description | String | Goal description (e.g., "Number of CTA clicks"). |
name | String | Goal name (e.g., "Clicks on CTA"). |
siteId | String | The project’s siteId . |
params | Object | Includes 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"
}'