hook_file_download() to catch when a user clicks on a download button for material

Hello Drupal Community,

I’m looking for a hook that can catch the instance a user clicks the download button on one of my reference material nodes of my website. The reason I’m doing this is so that i can send a request to my CRM application to add a tag to my existing contact record.

I’ve tried to implement hook_file_download() but that doesn’t seem to be working. I’m assuming my implementation may be wrong. Is there any advice on how to handle this event?

/*
 * Implements hook_file_download()
 */
function infusionsoft_contact_file_download($uri){
  global $user; // Establish User 
  $user_email = $user->mail; // Retrieve current user email
  dsm($user);

  $contactArray = array('Id'); //contact array

  $inf_return_contact_id = array($infusionsoft->contacts()->findByEmail($user_email,$contactArray));

  $contact_id = $inf_return_contact_id[0][0]['Id'];
  $tags = [102];

  foreach($tags as $tag_id) {
      $infusionsoft->contacts()->addToGroup($contact_id, $tag_id);
  }

}

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed