# Tracking Custom Goals

> Beware, this guide requires basic coding and javascript knowledge.

No analytics tool would be complete without giving you the opportunity to send custom goals yourself. In this guide, we will explore how this is possible with HockeyStack and how you can leverage this data in your dashboard.

### Within your code <a href="#block-88936e59a1ec4996a04a7c6bafb15419" id="block-88936e59a1ec4996a04a7c6bafb15419"></a>

Whether you want to track form submissions or specific button clicks, the general syntax to send this data back to HockeyStack is:

```javascript
HockeyStack.goal('Goal name' [, properties]);
```

Let's dissect this. The method takes in two arguments: a *required* `String` variable representing the name of the custom goal, and an *optional* `Object` variable consisting of any special property you want to send with your goal.

Here is an example goal you can send after the visitor added an item to their cart:

```javascript
HockeyStack.goal('Added to cart', {
	product: 'Rick Astley - Whenever You Need Somebody CD',
	productId: 23318,
	category: 'Music'
});
```

Keep in mind that this is also valid:

```javascript
HockeyStack.goal('Added to cart');
```

To send custom goals, you would need HockeyStack to be already loaded in the page. To make sure, you can define it as an empty object before the page loads or add a try-catch block around the goal method. See the disclaimer in [Identifying Users](https://docs.hockeystack.com/advanced-features/identifying-users) for more details.Custom goals currently fully support String and Number variables as properties. You can also send Arrays or Objects, but you wouldn't be able to use the full functionalities of custom goals in the HockeyStack dashboard.

### In Your HockeyStack Dashboard <a href="#block-84d458c066d04b4290c93a59d050d13c" id="block-84d458c066d04b4290c93a59d050d13c"></a>

After you send your custom goals, you can analyze them in your HockeyStack dashboard just like any other action.

Without any other configuration, custom goals show up in the **Users** page:

<figure><img src="https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/c8e70777-dbd6-4d4b-805f-69d8d78273b2/Screen_Shot_2021-06-15_at_10.50.23/w=1200,quality=90,fit=scale-down" alt=""><figcaption><p>Here you see HockeyStack's automatic tracking and custom goals together. To see the properties, just click on that specific goal.</p></figcaption></figure>

In order to track them as actual goals, there is one more step. Go to **Goals**, and click **+** at the top right corner. In your definition, choose **Custom Goals**. HockeyStack will list all the custom goals that you send to it here. You can choose whichever you want and define it as a normal goal.

This is *optional*, but you can also filter your custom goals through their properties. Click **+ property** and choose from the properties that HockeyStack detected automatically.

<figure><img src="https://318687664-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FedLASfWbQxGa0eYkwALS%2Fuploads%2F64v3UZV1Ehr119pKEuZt%2Fimage.png?alt=media&#x26;token=380ed86f-9573-46d0-8c6c-1af1c804b400" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hockeystack.com/technical-details/tracking/tracking-custom-goals.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
