Non-aggregatable metrics
Versions 3.0+ of the Push API support sending metric values to specific periods of time, using from – to timestamps.
If you want to create non-aggregatable (or unique) metrics, like for Churn Rate, Unique Visitor, etc., you need to store exact metric values for specific periods of time. Since such metrics cannot be aggregated, we simply can’t sum or take an average of daily values to display the monthly value. If you want to see the value for a Date Range, unique values need to be stored for each Date Range.
You can define these periods with the ‘periodFrom‘ and ‘periodTo‘ Date/Time.
- cURL
- PHP
- JavaScript
- Java
- Go
- Python
- C#
curl https://push.databox.com \
-u <your_token>: \
-X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.databox.v2+json' \
-d '{
"data":[
{
"$conversion_rate" : 0.09,
"periodFrom" : "2024-09-01 00:00:00",
"periodTo" : "2024-09-05 00:00:00"
}
]
}'
<?php
require_once __DIR__ . '/../../../vendor/autoload.php';
use Databox\Api\DefaultApi;
use Databox\ApiException;
use Databox\Configuration;
use Databox\Model\PushData as DataboxPushData;
use GuzzleHttp\Client;
execute();
function execute()
{
// Configure HTTP basic authorization: basicAuth
$config = Configuration::getDefaultConfiguration()
->setHost('https://push.databox.com')
->setUsername('<your_token>');
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/vnd.databox.v2+json'
];
$apiInstance = new DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new Client(['headers' => $headers]),
$config
);
$pushData = (new DataboxPushData())
->setKey('conversion_rate') // for e.g. sessions
->setValue(0.9)
->setPeriodFrom('2024-09-01T00:00:00Z')
->setPeriodTo('2024-09-05T00:00:00Z')
try {
$apiInstance->dataPost([$pushData]);
echo "Successfully pushed data to Databox";
} catch (ApiException $e) {
echo 'Exception when calling DefaultApi->dataPost: ' . $e->getMessage() . PHP_EOL . $e->getResponseBody() . PHP_EOL;
}
}
import {
ApiResponse,
Configuration,
DataPostRequest,
DefaultApi,
} from "databox";
const config: Configuration = new Configuration({
basePath: "https://push.databox.com",
username: "<your_token>",
headers: {
Accept: "application/vnd.databox.v2+json",
},
});
const dataPostRequest: DataPostRequest = {
pushData: [
{
key: "conversion_rate",
value: 0.9,
periodFrom: "2024-09-01 00:00:00",
periodTo: "2024-09-05 00:00:00",
},
],
};
const api = new DefaultApi(config);
try {
api
.dataPostRaw(dataPostRequest)
.then((response: ApiResponse<void>) => response.raw.json())
.then((responseBody) => {
console.log("Response data", responseBody);
});
} catch (error) {
console.log("Error: ", error);
}
import org.databox.ApiClient;
import org.databox.ApiException;
import org.databox.Configuration;
import org.databox.api.DefaultApi;
import org.databox.auth.HttpBasicAuth;
import org.openapitools.client.model.PushData;
import org.openapitools.client.model.PushDataAttribute;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://push.databox.com");
defaultClient.addDefaultHeader("Accept", "application/vnd.databox.v2+json");
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("Your_Databox_API_Token");
PushData data = new PushData()
.key("conversion_rate")
.value(0.9f)
.periodFrom("2024-09-01T00:00:00Z")
.periodFrom("2024-09-05T00:00:00Z")
DefaultApi apiInstance = new DefaultApi(defaultClient);
try {
apiInstance.dataPost(List.of(data));
} catch (ApiException e) {
e.printStackTrace();
}
}
}
// Example not available yet, check other languages
# Example not available yet, check other languages
// Example not available yet, check other languages