2

Is there any hook that can be used for logging contact views? We need to create report for that and first of course need to put that information to database.

4
  • I am unclear on what you are asking (but that might be me)? Commented Feb 21, 2019 at 13:12
  • I just want to write log every time when user views some contact. There is logging for edit or delete but not for view. Commented Feb 21, 2019 at 14:29
  • Jitendra has provided an approach for you to log contact summary views, but be aware that you can get contact information in many ways besides the viewing a contact summary. What is the purpose of the report? It will show you who viewed a contact summary page, not who viewed information about a contact.
    – Aidan
    Commented Feb 21, 2019 at 22:43
  • Aidan yes that's a little problem because we need to know who have seen contact informations in every way. Commented Apr 26, 2019 at 17:02

1 Answer 1

2

With contact view, I guess you mean when a contact summary page for a specific id is loaded you want me to increment a count number and store it in DB to display it in the report.

Currently, there is no such feature in core civicrm. You need to add a custom extension to add this functionality. See more details to build a simple ext at https://docs.civicrm.org/dev/en/latest/extensions/civix/. Some basic steps would be -

  • Add a custom field to extend Contact eg View Count.

  • Use hook_civicrm_summary to increment the value of this field for a specific contact ID.

  • You can use this custom field to show on any report provided by civicrm.

2
  • 1
    Yes. Thank you, so the summary is the right hook for that. That doesn't work in search results but I think its enough for now. Commented Feb 21, 2019 at 16:14
  • 1
    And no, we don't need the count. We need information about who has seen that contact and when. Commented Feb 21, 2019 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.