trackGoal
The trackGoal() method tracks completed goals. You can set any event as a goal, like when visitors sign up, buy your product, download a whitepaper or do anything else you think is important for your business.
Syntax
trackGoal(goalID[, conversionValue[, dimensions, [options]]])
GoalConversions.trackGoal(goalID[, conversionValue[, dimensions, [options]]])
GoalConversions.trackGoal(goalID[, conversionValue[, dimensions, [options]]])
GoalConversions.trackGoal(goalID[, conversionValue[, dimensions, [options]]])
GoalConversions.trackGoal(goalID[, conversionValue[, dimensions, [options]]])
GoalConversions.trackGoal(goalID[, conversionValue[, dimensions, [options]]])
GoalConversions.trackGoal(goalID[, conversionValue[, dimensions, [options]]])
Parameters
Parameter | Type | Description | Required |
---|---|---|---|
goalID | number | string | The ID of the goal you want to track. (To find a goal ID go to Menu > Analytics > Goals.) | Yes |
conversionValue | number | The value of the goal. It's used to calculate the goal revenue. | No |
dimensions | object | A list of custom dimensions that you want to pass with this event. Format for keys: dimensionX where X is the dimension ID. Format for values: percent-encoded (Use the encodeURIComponent() method to encode strings.) | No |
options | object | Optional object used to provide additional parameters to the request | No |
Options Object
Option | Type | Description | Required |
---|---|---|---|
currencyCode | string | Currency of the 'conversionValue' in ISO 4217 format. If not provided, the currency set in app settings will be used instead. | No |
Examples
To send a goal with the ID 27ecc5e3-8ae0-40c3-964b-5bd8ee3da059
and the value 20
:
_paq.push([
"trackGoal",
"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
20,
{ dimension1: encodeURIComponent("some value") },
{ currencyCode: "EUR" },
]);
GoalConversions.trackGoal(
"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
20,
{ dimension1: encodeURIComponent("some value") },
{ currencyCode: "EUR" }
);
GoalConversions.trackGoal(
"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
20,
{ dimension1: encodeURIComponent("some value") },
{ currencyCode: "EUR" }
);
GoalConversions.trackGoal(
"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
20,
{ dimension1: encodeURIComponent("some value") },
{ currencyCode: "EUR" }
);
GoalConversions.trackGoal(
"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
20,
{ dimension1: encodeURIComponent("some value") },
{ currencyCode: "EUR" }
);
GoalConversions.trackGoal(
"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
20,
{ dimension1: encodeURIComponent("some value") },
{ currencyCode: "EUR" }
);
GoalConversions.trackGoal(
"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059",
20,
{ dimension1: encodeURIComponent("some value") },
{ currencyCode: "EUR" }
);
Notes
- After you set up a goal in Analytics > Goals > Add a goal, the goal is tracked automatically. The trackGoal() method can be used in addition to the automatic method.
- For more on how to set up goals, see our help article.
Updated 6 days ago