“JavaScript event” goal

This type of goal lets you track events on a site (such as button clicks and form submissions) that occur without the page URL changing. If the URL changes, use the Page view goal.

When this type of goal is completed, the information is transmitted to Yandex.Metrica using JavaScript. This lets you track almost any custom event.

In E-commerce, use the goal_id field to transmit information about a conversion along with data about the action.

Attention. Users might complete a goal somewhere other than the site, like over the phone. To count these users, set up transmitting call tracker data to Yandex.Metrica. Then you can add calls to Yandex.Metrica reports and also use a special group of reports.
  1. How to create a “JavaScript event” goal
  2. Goal cost (value)
  3. Restrictions

How to create a “JavaScript event” goal

When you create a goal, you set its ID. When a goal is completed, the reachGoal method is called, and the specified ID is passed to it.

This type of goal can be used on Turbo pages.


Use IDs that aren't contained in in page URLs for the website. Otherwise, statistics also include session information for pages that contain the goal name in the URL.

The following symbols are not allowed in goal IDs: /, &, #, ?, =. If you want to add a plus sign to the ID, enter %2B in place of the + character.

  1. Use the reachGoal method on site pages.


    Clicking a button
    <form action="">
        <input type="button" onclick="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;" value="Order" />


    • XXXXXX is the tag ID.
    • TARGET_NAME is the goal ID.
    Filling in a form
    <form action="" method="get" onsubmit="ym(XXXXXX, 'reachGoal', 'TARGET_NAME'); return true;">


    • XXXXXX is the tag ID.
    • TARGET_NAME is the goal ID.
  2. In Yandex.Metrica, go to Settings, open the Goals tab, and click Add goal.
  3. In the Name field, enter a name for the goal to create.
  4. Set the condition to JavaScript event.
  5. Specify the goal ID.
  6. Click Add goal and save changes.
  7. Check whether the goal is working correctly.

Yandex.Metrica starts collecting stats just a few minutes after the settings are saved.

Goal cost (value)

Note. The value transmitted with the goal achievement in Yandex.Metrica is not considered if key goals are configured in Yandex.Direct.

When you transmit a goal achievement, you can assign a value to the conversion. This helps you take the goal's commercial viability into account. You can use a monetary value or symbolic units (1 — low, 10 — high). For example, you can set the average order amount for a service or product as the goal value.

This information is available in reports if you add the Income conversion metric in the Yandex.Metrica interface. For more information, see How to create a report on a goal.

Example of setting the goal value for a form:
<script type="text/javascript">
    var goalParams = {
       order_price: 1000.35,
       currency: "RUB"
<form action="" method="get" onsubmit="ym(XXXXXX, 'reachGoal', 'TARGET_NAME', goalParams); return true;">
You can also pass the event values (like file downloads) using the appropriate JavaScript API methods:


  • A maximum of 200 goals can be set for each tag.
  • The service registers a user completing the same goal on the same tag 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 a tag.
  • If you edit a tag or goal, previously collected information doesn't change.
  • If you delete a goal, information collected for it is no longer available in reports.

Select a question to find a solution.

Goals in Yandex.Metrica work the same way for any sources. Perhaps there aren't any users who have completed the goal from this source yet.

This might happen for the following reasons:
  • The goal condition in Yandex.Metrica doesn't cover all the possibilities. For example, the goal is set as going to the order confirmation page, but the site also allows quick orders without visiting this page.
  • The site user has a browser plugin that blocks the Yandex.Metrica tag, so this user isn't counted.
  • The user has an antivirus system with strict privacy settings.
  • The user has a slow internet connection, so the Yandex.Metrica tag didn't load on the target page.