Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Description:
This module provides a way to programmatically update the {node_counter} table (provided by the core statistics module).
This module listens to a URL in the format of /statistics/ajax/[nid]
where [nid]
is the id of the node you are looking to update the statistics for.
Alternatives to this module:
- Drupal 7 backport of #1209532: Count node views via AJAX in the statistics module - this was committed to Drupal 8 and has now been backported to Drupal 7 (in the 7.25 release). This Drupal 7 backport includes a lightweight bootstrap as well so will perform better on higher traffic websites.
- Boost has a statistics component to the module, so if you are already using boost, you may not need this module. Statistics_ajax is a extremely lightweight module, and would be great if you did not want to deploy boost to your site, and still have node statistics updated through AJAX.
Installation:
Sample code:
Sample javascript code (using jQuery):
// TODO, remove the hardcoded nid
var nid = 52;
// fire AJAX
$.ajax({
url: "/statistics/ajax/" + nid,
type: "POST",
dataTypeString: "text"
});
Sample response:
The response is return in the JSON format:
Example success message:
{ "status": "success", "data": "node updated" }
Example error message:
{ "status": "error", "data": "POST is not allowed" }
Project information
- Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed. - Maintenance fixes only
Considered feature-complete by its maintainers. - Module categories: Integrations
- 41 sites report using this module
- Created by wiifm on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.