WP Private Media is a WordPress plugin that can make specific uploads private and protect them from public viewing. Anything you can upload to the WordPress Media Library like a PDF, png, jpeg, or word document can be protected.
With this plugin you’ll have a special upload section that looks similar to the default Media Library. Anything uploaded there will be set as private. Similarly, you’ll have a “Add Private Media” button where you can insert the private media into your post. Just remember that private media will not be viewable by the public so it will not show up on a public post.
Download the WP Private Media plugin on the WordPress plugin repository.
The Pro version of this plugin allows you to choose which roles can access the private media.
Also included with the Pro version is the ability to track access to the files through Google Analytics. This requires that the logged in user visits a page on your website first so Google Analytics can start tracking the user (for example direct access to the private media without first visiting your website will not be tracked). To set this up, enter your Google Analytics Tracking ID on the WP Private Media settings page.