Drupal 10 - how to count the number of unique views of a node?
In Drupal 10 to count the number of unique views of a node by utilizing the Statistics module that comes with Drupal core. Follow these steps:
Enable the Statistics module: Go to the Extend page (/admin/modules) in your Drupal admin interface. Locate the "Statistics" module and enable it. Save the configuration.
Configure access permissions: Navigate to the People > Permissions page (/admin/people/permissions) and ensure that the appropriate roles have the "View content statistics" permission enabled.
View node statistics: Drupal will track the view in its database when a user views a node. To see the statistics for a specific node:
a. Go to the content listing page (/admin/content).
b. Find the node you want to check and click on the "Edit" link for that node.
c. On the node edit page, scroll to the "Statistics" tab. Click on it.
You should now see the statistics for that node, including the number of total views, unique views, and other relevant information.
Note that the Statistics module tracks views only after it has been enabled. Views that occurred before enabling the module won't be counted. Additionally, the Statistics module does not differentiate between anonymous users, so the count includes both authenticated and anonymous user views.