<script>
/*
This example requires jQuery.
Put this code in the HTML of the success page of the order flow.
Warning: JavaScript is executed client side so your API key is exposed to users.
Make sure to restrict the API key to the defined metric key, otherwise users
will be able to create new metrics.
*/
(function ($) {
var apiKey = 'your-api-key';
var endpoint = 'https://api.downnotifier.com/api/v1/metric/log';
var key = 'orders';
var data = {
'apikey': apiKey,
'key': key,
'value': 1,
'type': 'counter'
};
//log order
$.get(endpoint, data);
})(jQuery);
</script>
<?php
$apiKey = 'your-api-key';
$endpoint = 'https://api.downnotifier.com/api/v1/metric/log';
$key = 'orders';
$parameters = [
'apikey' => $apiKey,
'key' => $key,
'value' => 1,
'type' => 'counter',
];
$url = $endpoint.'?'.http_build_query($parameters);
//log order
file_get_contents($url);