Here's how the calculated metric is defined in the Google Analytics web interface:
Name Profit
External Name calcMetric_Profit
Formatting Type Currency (Decimal)
Formula {{Revenue}} - {{Shipping}} - {{Tax}}
The "External Name" field has this description:
The external name is used to uniquely identify the calculated metric when querying via API. External names may contain alphanumeric and underscore characters only. Special characters, symbols, and spaces are not allowed.
When I request the metric from v4 of the reporting API, using this request:
POST https://analyticsreporting.googleapis.com/v4/reports:batchGet?key=<redacted>
{
"reportRequests": [
{
"dateRanges": [
{
"startDate": "2018-01-01",
"endDate": "2018-01-22"
}
],
"metrics": [
{
"expression": "ga:calcMetric_Profit"
}
],
"viewId": "<redacted>"
}
]
}
I get this response:
400
{
"error": {
"code": 400,
"message": "Invalid value 'ga:calcMetric_Profit' for metric parameter.",
"status": "INVALID_ARGUMENT"
}
}
Am I doing something wrong?
Is this related to calculated metrics still being in Beta?