Possible solutions to get statistics, counts on links clicked from your Drupal website:
- Link Click Count module – The Link Click Count module helps you to monitor the traffic to your website by creating link fields. These link fields can be individual links or internal/external links that can be added to the content type. It can track internal, external links. A simple solution for tracking both internal and external link clicks. It also ensures that each link (internal or external) will be tracked individually. This means that if you have two nodes that reference the same link, you can see the link click counts for each link individually. This is perfect for A/B testing. Get the module here: https://www.drupal.org/project/link_click_count.However, as of this writing, the module is unsupported for Drupal 9 and 10 onwards due to a security issue which has not been fixed yet.Use cases, you need Link Click Count:
- If you want to find how many users clicked on “Register Now” link you have placed on a landing page.
- Boost your affiliate program based on numbers of clicks on the outbound links.
- Google Analytics / Google Tag Manager
Google Analytics and the Google Analytics Module track outbound links, but they don’t provide you with enough detail to out of the box. Read a useful resource here: https://www.analyticsmania.com/post/track-clicks-with-google-analytics-4-and-gtm/ - Statistics Core module
Limited functionality unless you have developer support to develop custom triggers. Out of the box, the core module only counts page impressions and views of the node or page, not fields like URLs, especially external. - Statistics Counter module
Provides additional functionality for the Statistics core module by providing more information from Views like:
Content statistics: Most recent view (Most recent view)
Content statistics: Total views (Total views)
Content statistics: Views this month (Views this month)
Content statistics: Views this week (Views this week)
Content statistics: Views this year (Views this year)
Content statistics: Views today (Views today)However, again, this does not support click counts on URLs from the Link fields or similar. But should be useful if tracking node or page counts, impressions or clicks. - Redirects – using redirects module, methods, or strategies, for instance using the Statistics modules that count the page or node counts; the actual page can then be redirected to the external URLs once count has been triggered and captured from the node visits.
- Shurly module – a URL shortener module for Drupal nodes/content which can be used in combination with the Statistics and/or Redirects method. However, as of this writing, the module is still in dev version for Drupal 9 and 10 onwards, and triggers some errors still. Use at your risk for now, and follow, support the development. Get the module here: https://www.drupal.org/project/shurly
Some useful resources and related issues and readings:
https://www.drupal.org/project/field_redirection
https://www.drupal.org/project/field_redirect
https://www.drupal.org/forum/support/post-installation/2011-08-18/any-way-to-count-external-link-hits
https://stevepolito.design/blog/track-link-clicks-drupal
https://www.drupal.org/project/shurly