I have a custom content type (bundle, drupal 7) which has a link (rules link module) and I want to log the number of clicks on this link. At the moment I've an integer field in the bundle and I use rules to increment it and save the node every time the link is clicked. I think this method is not efficient and has also security implications so I ask you suggestions on how to do it better. I considered writing a small custom rule (module) which increment the value directly in the field table which probably would have less overhead but I think it would still not be very secure as I don't know how to handle a large number of clicks in a short time. Thanks for any help.
A possible alternative to "record the clicking of such link" is to use the Message module to create a message like so:
- Date = date the link was clicked.
- User target = the user who clicked the link.
- Message type = something like "Link of custom content type clicked".
- Message text = whatever you want and possibly using "Replacement tokens" to have any of the tokens that you have available in your rule also included in your message text (should you have any such need).
Since messages are entities, you could add any additional fields you may need to complete such custom logging.
With this approach, you've reduced your question to (eg) creating an appropriate view (and/or chart?) of all such messages that got created.