sendGoal
The sendGoal() method tracks completed goals. You can set any event as a goal, like when users sign up, buy your product, download a whitepaper or do anything else you think is important for 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 |
|---|---|---|---|
| ID | string | Yes | The ID of the goal you want to track. (To find a goal ID, go to Menu > Analytics > Goals.) |
| revenue | NSNumber | No | The value of the goal. It's used to calculate the goal revenue. |
| 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 the value 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 with conditions (for example URL or event rules). Those conversions are counted when incoming tracking matches the rules. You do not have to call
sendGoal()for that kind of goal. - Use
sendGoal(ID:revenue:)/sendGoal(ID:revenue:currencyCode:)to record a manual goal conversion from the app (for example when automatic rules do not fit, or you need a dynamic revenue value). Avoid counting the same user action twice if it would also satisfy an automatic goal for the same goal ID. - For more on goals, see our help article.
Related methods
Updated 16 days ago