function hook_better_statistics_ajax in Better Statistics 7
Handle statistics data passed via AJAX.
This hook will be invoked for every call to the Statistics AJAX API callback, regardless of the type of data that is being passed. Also note that you can listen for a specific type of payload with hook_better_statistics_ajax_TYPE.
Parameters
$type: The type of data being handled. Better Statistics itself provides two, but it's possible for any module, including your own, to provide more.
- accesslog
- entity_view
This value should correspond directly to what is used to call the bs() facade in JS. For example, bs('accesslog') and bs('entity_view').
$payload: An associative array of data to be logged, stored, or reacted upon in some way. This data is the final result of merging server-side collected defaults with values provided on the client-side. Note that the client-side data takes precedence over the server-side data.
Related topics
1 function implements hook_better_statistics_ajax()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
1 invocation of hook_better_statistics_ajax()
- better_statistics_ajax_handler in ./
better_statistics.ajax.inc - Handles Better Statistics AJAX POST requests.
File
- ./
better_statistics.api.php, line 289 - This file contains no working PHP code; it exists to provide additional documentation for doxygen as well as to document hooks in the standard Drupal manner.
Code
function hook_better_statistics_ajax($type, $payload) {
switch ($type) {
case 'my_custom_type':
db_insert('my_custom_type_table')
->fields($payload)
->execute();
break;
}
}