How can create a download counter?
The only Drupal-centric of doing this is by making sure your content type is utilizing the Private files directory for your file field. Otherwise, downloads are served by the web server.

When private file storage is utilized, this enables Drupal as the file download gatekeeper through its /system/files/{filepath} route. When the controller for the download route is called, it evokes hook_file_download() which can be used to store your ongoing file download count. 

For example a custom module could implement:

/**
 * Implements hook_file_download().
 */
function MYMDOULE_file_download($uri) {
  // @TODO: Store/Increment count for unique $uri.
}


Then reference the count when building variables for your node template:

/**
 * Implements hook_preprocess_node().
 */
function MYTHEME_preprocess_node(array &amp;$variables) {
  if (isset($variables['node']-&gt;field_MYFILE_FIELD)) {
    $uri =  $variables['node']-&gt;field_MYFILE_FIELD-&gt;entity-&gt;getFileUri();
  } else {
    $uri = '';
  }
  // @TOOD: lookup count for $uri and inject it into
  // $variables['field_MYFILE_FIELD_count'] for display
}