PHP code example of automattic / jetpack-stats
1. Go to this page and download the library: Download automattic/jetpack-stats library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
automattic / jetpack-stats example snippets
use Automattic\Jetpack\Config;
// Here we enable the Jetpack packages.
$config = new Config();
$config->ensure( 'stats' );
}
add_action( 'plugins_loaded', 'jpcs_load_plugin', 1 );
add_filter( 'stats_array', 'filter_stats_array_add_custom_stat' );
/**
* Add custom stat to the stats tracking data.
*
* @param param array $kvs The stats array in key values.
* @return array
*/
function filter_stats_array_add_custom_stat( $kvs ) {
$kvs['custom_stat'] = 'my_custom_stat'
return $kvs;