Skip to main content

Create a new goal for an experiment

Goal

Goals are metrics to track campaign success. This tutorial creates a Click goal to count clicks on the .cta-button element. See the goal creation guide for more information.

Requirements

  • access token

The Automation API requires an access token. Retrieve the token programmatically by following the instructions in the obtaining an access token section.

Create the goal

Endpoint:

POST https://api.kameleoon.com/goals
NameTypeDescription
descriptionStringGoal description (for example, "Number of CTA clicks").
nameStringGoal name (for example, "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"
}'