sendGoal
The sendGoal() method tracks completed goals. You can set any event as a goal, such as user sign-ups, product purchases, whitepaper downloads or other actions that are important to your business.
Syntax
PiwikTracker.sharedInstance()?.sendGoal(ID: "goalID", revenue: conversionValue)
PiwikTracker.sharedInstance()?.sendGoal(ID: "goalID", revenue: conversionValue, currencyCode: "currencyCode")[[PiwikTracker sharedInstance] sendGoalWithID:@"goalID" revenue:@(conversionValue)];
[[PiwikTracker sharedInstance] sendGoalWithID:@"goalID" revenue:@(conversionValue) currencyCode:@"currencyCode"];Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Goal ID | string | Yes | The ID of the goal you want to track. You can find a goal ID in Menu > Analytics > Goals.) |
| revenue | NSNumber | No | The value of the goal. The revenue associated with the goal conversion. |
| currencyCode | string | No | The ISO 4217 currency code for the revenue value. Example: USD, EUR, PLN. If not provided, the currency configured for the site/app in Piwik PRO is used. |
Examples
To send a goal with the ID 27ecc5e3-8ae0-40c3-964b-5bd8ee3da059 and a value of 20:
PiwikTracker.sharedInstance()?.sendGoal(ID: "27ecc5e3-8ae0-40c3-964b-5bd8ee3da059", revenue: 20)[[PiwikTracker sharedInstance] sendGoalWithID:@"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059" revenue:@20];To send a goal with an explicit currency code (USD):
PiwikTracker.sharedInstance()?.sendGoal(ID: "27ecc5e3-8ae0-40c3-964b-5bd8ee3da059", revenue: 20, currencyCode: "USD")[[PiwikTracker sharedInstance] sendGoalWithID:@"27ecc5e3-8ae0-40c3-964b-5bd8ee3da059" revenue:@20 currencyCode:@"USD"];Notes
- In Analytics, a goal can use Track goal automatically option with conditions, such as URL or event rules. Those conversions are counted automatically when tracked events or URLs match the configured rules. You don't need to call
sendGoal()for this goal type. - Use
sendGoal(ID:revenue:)orsendGoal(ID:revenue:currencyCode:)to record a manual goal conversion from the app. This is useful when automatic rules aren't suitable or when the revenue value varies between conversions. Avoid counting the same user action twice if it would also satisfy an automatic goal for the same goal ID. - For more information on goals, see Set up goals.
Related methods
Updated 2 months ago
Did this page help you?