trackGoal
The trackGoal() method tracks completed goals in your app. 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
const options = {
revenue: conversionValue,
visitCustomVariables: { index: { name: 'name', value: 'value' },
customDimensions: { dimensionID: 'value', dimensionID: 'value', },
};
await PiwikProSdk.trackGoal('goalID', options);
Parameters
goalID (string , required)
The ID of the goal you want to track. (To find a goal ID go to Menu > Analytics > Goals.)
options
Goal options: an object containing three properties.
conversionValue (number, optional)
The value of the goal. It’s used to calculate the goal revenue.
customDimensions
An object that specifies custom dimensions.
visitCustomVariables
An object that specifies visit custom variables.
Examples
To send a goal with the ID 27ecc5e3-8ae0-40c3-964b-5bd8ee3da059
and the value 20
:
const options = {
revenue: 20,
visitCustomVariables: { index: { name: 'name', value: 'value' },
customDimensions: { dimensionID: 'value', dimensionID: 'value', },
};
await PiwikProSdk.trackGoal('27ecc5e3-8ae0-40c3-964b-5bd8ee3da059', options);
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 goals, see our help article.
Updated 6 days ago