Metrica

Goals

Goals let you track specific user actions, such as:

Viewing a specific page (the order confirmation page, or others)

We recommend using the Page view type of goal.

Clicking a button

We recommend using the JavaScript event type of goal. The goal ID is specified when the goal is created. When the goal is completed, the reachGoal method is called and this ID is passed to it. For example:

<html>
    ...
    <form action="">
        ...
        <input type="button" onclick="yaCounterXXXXXX.reachGoal('ORDER'); return true;" value="Order" />
    </form>
    ...
</html>

where

  • XXXXXX is your counter number.
  • ORDER is the goal ID.
Filling in a form

We recommend using the JavaScript event type of goal. The goal ID is specified when the goal is created. When the goal is completed, the reachGoal method is called and this ID is passed to it. For example:

<html>
    ...
    <form action="" method="get" onsubmit="yaCounterXXXXXX.reachGoal('ORDER', function () {
    alert('Данные успешно отправлены');
}, <Контекст, доступный по ключевому слову this внутри callback-функции>); return true;">
        ...
    </form>
    ...
</html>

where

  • XXXXXX is your counter number.
  • ORDER is the goal ID.
A sequence of goal actions (the sales funnel)

We recommend using the Multi-step goal type of goal.

Viewing a certain number of pages on the site

We recommend using the Page depth type of goal.

Clicking an external link, downloading a file, or clicking an email address

We recommend using the Page view type of goal.

Creating a goal

To create a goal, follow these steps:

  1. Click Add goal.
  2. In the Name box, enter a name for the goal to create.
  3. If you need to create a retargeting goal, select the Retargeting option. If this option is not selected, a conversion goal will be created.
  4. Go to the appropriate tab:

    Page depth

    This type of condition lets you set the specific number of pages viewed by the site user. To set a goal, specify an integer greater than 1 in Pageviews.

    Page view

    This type of condition lets you set a specific page or pages on the site that you are interested in visits to.

    You can enter the full URL or part of a URL, or use a regular expression.

    Possible ways to set conditions:

    • “url: matches”. The full URL of the target page is specified.
    • “url: contains”. Part of a URL is specified. This option is usually used if there are multiple target pages and they can be combined with a single condition. Specify as much of the URL as possible so the goal is completed only on the desired pages.
    • “url: begins with...”. Only the first part of the URL is specified. Use this type of condition if you need to track pageviews in subdirectories.

      For example, if the set condition is “example.com/abc/”, the goal will be completed on example.com/abc/1, example.com/abc/2, and example.com/abc/1/2/3.
    • “url: regular expression”. Used for tracking URLs that match a custom pattern.

    You can use multiple conditions (up to 10) for setting page URLs. These conditions are combined using the OR logical operator. So the goal is considered completed if at least one of the set conditions is met.

    JavaScript event

    This type of condition lets you track events on a site (button clicks, form submissions, and other events).

    When this type of goal is completed, the information is transmitted to Yandex.Metrica using JavaScript. The goal ID is specified when the goal is created. When the goal is completed, the reachGoal method is called and this ID is passed to it. In Ecommerce, information about a completed goal is transmitted using the goal_id field along with the action data.

    In this way, you can track almost any events.

    Restriction. 

    Use ID values that aren't contained in the site's page URLs.

    IDs must not contain the following symbols: /, &, #, ?, =.

    Multi-step goal

    This type of condition lets you set a sequence of steps that the user completes to reach a goal. Each step is described using Page view or JavaScript event types of goals.

    When creating a goal, note the following:

    • A multi-step goal may contain a maximum of five steps.
    • Don’t forget that each step must require completing the previous step. For example, if a user can skip the first step and immediately perform the second step, the goal is not considered completed.
    • The steps don't have to be completed directly one after another. On their way to the goal, users might visit different pages of the site and perform other actions not related to the goals of the steps.
  5. Click Add goal. The created goal is shown in the list of goals.
  6. Click Save.

If goals are set up this way, Yandex.Metrica begins collecting statistics for the created goals several minutes after saving settings. You can view statistics in the Conversions report.

Note. 
  • Up to 200 goals can be set for each counter.
  • The service registers a user completing the same goal on the same counter no more than once per second.
  • During a single user session, the service can register up to 400 completions of all the goals created for the counter.
  • If you edit a counter and change the goal information, all the previously collected information is not recalculated.
  • If you delete a goal, the information collected for it will not be available in reports.
  • Some users might complete the goal somewhere other than on the site, such as by making a phone call. To count this type of data, you can use Target Call.

  • If you want the goal to be completed for pageviews with URLs containing the plus sign, put “%2B” in the template in place of the + character.

    Example

Verifying a goal

To verify that information about the goal was sent, you can use the _ym_debug parameter in the page URL with the value 1. In this case, a message about completed goals is output to the browser console.

The browser console usually opens with the keyboard shortcut Ctrl + Shift + J ( + + J for Mac).

http://example.com/?_ym_debug=1

If there is no data in the console, this may be caused by the following reasons.

For Page view type goals:

  • The URL of the current page isn't specified in the goal settings.
  • The conditions in the goal settings are too strict (for example, the condition is “url: matches” instead of “url: contains”).

For JavaScript event types of goals:

  • The goal ID in the reachGoal method does not match the ID in the counter settings.
  • The code for calling the reachGoal method is missing or is not run.