Creating a goal

Creates a counter goal.

Request

POST

https://api-metrica.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,
        "goal_source": "string",
        "is_favorite": false,
        "flag": "basket",
        "conditions": [
            {
                "type": "string",
                "url": "string"
            }
        ]
    }
}

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: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

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: 0

Max length: 255

steps*

Type: ConditionalGoal[]

List of steps in a multi-step goal.

Min items: 0

Max items: 5

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

default_price

Type: number<double>

Default goal cost.

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

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: 2

name*

Type: string

Goal name.

Min length: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

default_price

Type: number<double>

Default goal cost.

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

EmailGoal

Clicks or taps on an email address.

Name

Description

name*

Type: string

Goal name.

Min length: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

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: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

MessengerGoal

Click-through to a messenger. The goal will be achieved once the user clicks the link to the messenger.

Name

Description

name*

Type: string

Goal name.

Min length: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

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: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

default_price

Type: number<double>

Default goal cost.

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

PhoneGoal

Clicks or taps on a phone number.

Name

Description

name*

Type: string

Goal name.

Min length: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

hide_phone_number

Type: boolean

Hide the phone number on desktops.

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:

  • 0: False (default).
  • 1: True.

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: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

SocialNetworkGoal

Click-through to 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: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

UrlGoal

Pageviews. Achieved when at least one condition is met.

Name

Description

name*

Type: string

Goal name.

Min length: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

Enum: basket, order, ``

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

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: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

default_price

Type: number<double>

Default goal cost.

duration

Type: integer<int32>

Session duration in seconds.

Min value: 1

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

GoalE

Name

Description

name*

Type: string

Goal name.

Min length: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

default_price

Type: number<double>

Default goal cost.

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

GoalCondition

List of structures with the goal conditions.

Name

Description

type*

Type: string

Condition type:

  • contain: Contains.
  • exact: Matches exactly.
  • start: Starts with.
  • regexp: Matches a regular expression.
  • action: Special type of condition for the "JavaScript event" goals.
  • messenger: Special type of conditions for "form" goals, path in the DOM tree.
  • all_files: Attribute for "Open messenger" goals.
  • file: Downloading a specific file for "File downloads" goals.
  • search: Attribute for "Site search" goals.
  • all_social: Special type of condition for social goals (all social networks).
  • social: Special type of condition for social goals (a specific social network).
  • regexp_action: JS event matches a regular expression (used exclusively in a step of a multi-step goal).
  • contain_action: JS event contains (used exclusively in a step of a multi-step goal).

url

Type: string

The value depends on the goal type:

  • Page view. URL to page or page section for the condition.
  • Click on email or Click on phone number. Email or phone number specified in the links on the site. Learn more about tracking clicks on email addresses or phone numbers.
  • Open messenger. Name of the messenger retrieved by the GET management/v1/messengers method, or the all_messengers value.
  • Site search. GET parameter used for searching on the site. Yandex Metrica automatically recognizes the q, text, query, or search parameters. If the site uses a different parameter, specify it in the request.
  • File download. File name, for example, example.pdf. The value can be empty if you need to track all the files downloaded on the site.
  • Click-through to social network. Name of the social network obtained via the GET management/v1/social_networks method, or the all_social value.

ConditionalGoal

List of steps in a multi-step goal.

Name

Description

name*

Type: string

Goal name.

Min length: 0

Max length: 255

type*

Type: string

Goal type:

  • url: Pageviews.
  • number: Number of views.
  • step: Multi-step goal.
  • action: JavaScript event.
  • phone: Click on phone number.
  • email: Click on email.
  • payment_system: Payment system.
  • messenger: Click-through to a messenger.
  • file: File download.
  • search: Site search.
  • social: Click-through to social media accounts.
  • visit_duration: Session duration.

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:

  • basket: Shopping cart, shopping cart page.
  • order: Order, order confirmation page.

goal_source

Type: string

Indicates how the goal was created:

  • user: The goal was created by a Yandex Metrica user.
  • auto: The goal was created automatically. Such goals include automatic goals and the Call goal (created when passing call data).

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:

  • 0: False (default).
  • 1: True.

Responses

200 OK

OK

Body

application/json
{
    "goal": {
        "id": 0,
        "name": "string",
        "type": "string",
        "default_price": 0,
        "goal_source": "string",
        "is_favorite": false
    }
}

Name

Description

goal*

Type: GoalE