Creating a goal
Creates a counter goal.
Request
POST
https://api-metrika.yandex.net/management/v1/counter/{counterId}/goals
Path parameters
| Name | Description | 
| counterId* | Type: integer<int32> ID of the counter that you want to create a goal for. | 
Body
application/json
{
    "goal": {
        "id": 0,
        "name": "string",
        "type": "string",
        "default_price": 0,
        "is_favorite": false,
        "status": "string",
        "conditions": [
            {
                "type": "string",
                "url": "string"
            }
        ],
        "flag": "basket"
    }
}
| Name | Description | 
| goal* | Type: ActionGoal or CompositeGoal or DepthGoal or EmailGoal or FileGoal or MessengerGoal or PaymentSystemGoal or PhoneGoal or SiteSearchGoal or SocialNetworkGoal or UrlGoal or VisitDurationGoal | 
ActionGoal
JavaScript event.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
CompositeGoal
Multi-step goal.
Used for grouping and setting the order of usual goals.
Page view
 and JavaScript event
 goals can be steps of a multi-step goal.
A step is considered completed if all the previous steps were completed and all the current step's conditions were met.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| steps* | Type: ConditionalGoal[] List of steps in a multi-step goal. Min items:  Max items:  | 
| type* | Type: string Goal type: 
 | 
| default_price | Type: number<double> Default goal cost. | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
DepthGoal
Page depth. The goal is considered achieved if the user viewed the specified number of site pages.
| Name | Description | 
| depth* | Type: integer<int64> Number of pages viewed by the user. Min value:  | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| default_price | Type: number<double> Default goal cost. | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
EmailGoal
Clicks or taps on an email address.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
FileGoal
File download. The goal is considered achieved if the user downloaded any file or a specific file.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
MessengerGoal
Click-through to a messaging app. The goal will be achieved once the user clicks the link to the messaging app.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
PaymentSystemGoal
Payment systems. The goal is considered achieved if the user makes a payment via a payment system.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| default_price | Type: number<double> Default goal cost. | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
PhoneGoal
Clicks or taps on the phone number.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| hide_phone_number | Type: boolean Hide the phone number on desktop devices. | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
SiteSearchGoal
Site search. The goal will be achieved when performing a site search if there is at least one match in the URL specified in the GET parameters.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
SocialNetworkGoal
Click-through to a social network. The goal will be achieved once the user clicks the link to the social network.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
UrlGoal
Pageviews. Achieved when at least one condition is met.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 Enum:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
VisitDurationGoal
Session duration. The goal will be achieved if the session duration exceeds the specified one.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| default_price | Type: number<double> Default goal cost. | 
| duration | Type: integer<int32> Session duration in seconds. Min value:  | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
GoalE
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| default_price | Type: number<double> Default goal cost. | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
GoalCondition
List of structures with the goal conditions.
| Name | Description | 
| type* | Type: string Condition type: 
 | 
| url | Type: string The value depends on the goal type: 
 | 
ConditionalGoal
List of steps in a multi-step goal.
| Name | Description | 
| name* | Type: string Goal name. Min length:  Max length:  | 
| type* | Type: string Goal type: 
 | 
| conditions | Type: GoalCondition[] List of structures with the goal conditions. | 
| default_price | Type: number<double> Default goal cost. | 
| flag | Type: string Goal type for Yandex Market clients: 
 | 
| id | Type: integer<int64> ID of the goal. Specify this parameter when changing and deleting a counter goal. | 
| is_favorite | Type: boolean Whether the goal is favorite: 
 | 
| status | Type: string | 
Responses
200 OK
OK
Body
application/json
{
    "goal": {
        "id": 0,
        "name": "string",
        "type": "string",
        "default_price": 0,
        "goal_source": "string",
        "is_favorite": false,
        "status": "string",
        "conditions": [
            {
                "type": "string",
                "url": "string"
            }
        ],
        "flag": "basket"
    }
}
| Name | Description | 
| goal* | Type: ActionGoal or CompositeGoal or DepthGoal or EmailGoal or FileGoal or MessengerGoal or PaymentSystemGoal or PhoneGoal or SiteSearchGoal or SocialNetworkGoal or UrlGoal or VisitDurationGoal | 
No longer supported, please use an alternative and newer version.