TL;DR – I’ve created a WordPress plugin that tracks PDF views on your website, in Google Analytics. It’s free, and unlike other solutions, captures 100% of traffic (including Direct and Organic Search).
Please note I can not provide any support or troubleshooting for this plugin.
How do you track Google Analytics data on PDF files?
With 7 out of 10 websites using Google Analytics1, it clearly holds the title of the most popular Analytics platform. But one major downside in how Google Analytics works, is that it can only track visits to the HTML pages on your website2. Unlike previous generations of Web Analytics packages that relied on Log File data, GA cannot see traffic landing directly on your other media files, including the enterprise and public sector favourite, PDF.
Finance, insurance and public sector websites are particularly affected by this problem. Important information, data, forms, product/service details and brochures, all get delivered in PDF format. These institutions do not want to convert their PDFs into webpages, as they cant be easily controlled, versioned, and compliance checked. Even those that do convert, usually link to and promote a PDF version of the information.
Restaurants also favour PDF files for their food and drink menus, but cannot see if anyone downloads or reads them.
I’ve seen this firsthand with several clients, that had PDF documents ranking competitively in Google. None of this traffic was measurable though. The solution was to build “PDF Analytics”, a plugin for WordPress that makes those visits visible in Google Analytics for the first time.
PDF Analytics intercepts any request for a .pdf file on your website and collects the visitor’s Google Analytics cookie data (if any), UTM tracking tags in the URL and several other metrics. These are then sent to Google Analytics via their official API. The PDF file is then served as usual, from the same URL and without the visitor knowing any different.
To make it fast and reliable, the PDF tracking script runs independently of WordPress. So your PDF files are still accessible if your WordPress database goes down or has an error, plus isn’t affected by any problem-plugins that might otherwise slow it down. It does not “phone home” to me or any third party other than Google Analytics itself, so will pass corporate compliance and security audits.
If that wasn’t enough, I’m releasing the plugin for free! Just click here to download the ZIP file, then upload it to your WordPress site under “Plugins” > “Add New” > “Upload”. Then “Activate” it and enter your Google Analytics Tracking/Site ID on the settings page.
If you’d like to say thank you, please share a link to this announcement with anyone that you know, who uses WordPress and Google Analytics.Track visits to your website's PDF files in Google Analytics. Free plugin for WordPress. Click To Tweet
Frequently Asked Questions
How do I install PDF Analytics?
Download the plugin as a ZIP file here, then upload it to your WordPress site by going to “Plugins” > “Add New” > “Upload Plugin”. Then click “Activate” next to the plugin, from the Plugins page. You will see a success message, linking through to settings page, which can also be found at “Settings” > “PDF Analytics” in the WordPress control panel. You will need to fill and submit three pieces of information (two are filled for you). After saving these settings, PDF Analytics will start sending PDF traffic data to Google Analytics.
How does it work?
All requests for
Does your plugin use “log files”?
No log files involved – PDF Analytics uses .htaccess to reroute all PDF file requests to a PHP script, which sends data to the Google Analytics API and then serves the content of the PDF.
Are any redirects involved?
No. PDF Analytics uses an “internal rewrite” to direct PDF requests to the tracking script. As long as a PDF file exists at the given URL, it’ll return a 200 (OK) HTTP Status code, and a 404 (Page Not Found) if it doesn’t exist.
How safe is PDF Analytics?
The software is free and open source, so comes without warranty or liability. It has been tested on multiple sites without any issues. The tracking code runs independently of WordPress, so your PDF files remain accessible, even when your WordPress site has a database or plugin issue. The publicly accessible PHP file has no database access and does not write to any files. The plugin settings require admin level access to your WordPress site and cannot be changed without them. The codebase is purposely small and tidy, making code audits fast and simple.
Does the software “phone home” or share the data?
PDF Analytics will only send out visitor data to the official Google Analytics API. I track the number of plugin downloads from the site in Google Analytics, but don’t know who you are exactly. No data is sent to me when activating, using or deactivating the plugin. I will not know which websites use it or see your traffic data. I may start a mailing list to give information about updates, but you can opt-in and opt-out of this at any time.
Do you require access to the Google Analytics account?
No. PDF Analytics only asks for your GA Tracking/Website ID, which is non-sensitive information and visible in the Google Analytics tracking code on your website. This tells Google which GA account to log the data for. Neither the plugin or I will have any access to your Google Analytics account or login details – not even read-only access.
How do I uninstall PDF Analytics?
Just click “Uninstall” next to the plugin on the “Plugins” page. You can also click “Delete” afterwards, to physically remove the files. The PDF Analytics entry in your .htaccess file should be deleted automatically upon Uninstall, but it’s worth double checking. Open your .htaccess file and delete anything between “# BEGIN PDF Analytics” and “# END PDF Analytics”. If you don’t see this in your .htaccess, it means that we deleted this for you.