How to Track Printed Pages in Google Analytics

How To Track Printed Pages & Print Method In Google Analytics

It can sometimes be important to know if your content has been printed. The usual way to track this (in Google Analytics and other web analytics tools) is to use a “Print button” with an onclick event that sends the data to the tool.

However, not every website has a print button, and there are many other ways to print a page:

  • Printing from the Browser Menu
  • Right Click and choose Print from the Right Click Menu
  • Ctrl+P (Windows) or Cmd+P (Mac)

In this blog post I show you how to track printing, and what method used to print the page.

How To Track Printed Pages & Print Method In Google Analytics

About the Script used for Tracking Printing in Google Analytics

The script in this blog post is based on a script made by TJ VanToll, and is described in his blog post called Detecting Print Requests with Javascript.

The script and solution is a little bit “hacky”, and that is described below.

Opera Browser and Print Tracking

As he describe in his blog post, you have to use different methods for different browsers to detect printing. So what I have done is to take his script, and added tracking of printing method to my script. The reason for this is not only curiosity, but also that printing from the Opera browser can’t be detected using only javascript (perhaps this will change when Opera starts to use Webkit as the engine for the browser).

To get some understanding of printing from a Opera browser, you will have to rely on Print Button tracking and tracking of Ctrl/Cmd+P. Printing from Browser Menu or Right Click + Print can’t be tracked from a Opera browser.

Chrome Browser and Print Tracking

Chrome is a different “beast” as well. It will in most of the time fire several events, and only the first event will show the correct Print Method. Because of this I only allow the script to run once.

General things about this script for Print Tracking

Other things to be aware of is that most browsers based on my testing (Internet Explorer, Chrome and Firefox) will tell you that the page was printed even if you cancel printing, while in Safari you will have to Print the Page or choose Print Preview for the script to “kick off”.

If you right click but don’t print, and instead chooses to print from the Browser Menu, this will probably be tracked as Right Mouse Button Printing.

Script for tracking Print in Google Analytics

 Some final words

This script relays on jQuery, so you will need that installed on your site to get this script to work.

If you think the code could be improved, feel free to chime in (I’m not a programmer).

The code in this post was written in 2013, and today I would have done everything in Google Tag Manager. LunaMetrics has written the blog post Tracking Page Prints with Google Tag Manager that will show you how to do this.

Be the first to comment on "How to Track Printed Pages in Google Analytics"

Leave a comment

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.