Analytics and Search Marketing Tips
Have you ever wondered if people are printing pages from your website?
Wonder no more…here is a solution to track all the methods people use to print a page on your website. We will show you how to capture this data whether they;
A common solution is to listen for clicks onto your website’s print button. This works well if everyone used that button. However, there are several other ways that users can print a page, as detailed above. The Google Analytics tracking solution we provide below, tracks all print methods as it hooks into the browser to listen to events just prior to the print dialog appearing.
Before we begin, it is important to understand that if a user initiates the print dialog and then cancels, this code will still track it as a print. Thus, I label it in Google Analytics as more of an intent. The tracking code below can be implemented anywhere below your Google Analytics script. Depending on if you use Google’s Classic Analytics (ga.js/dc.js) or Universal Analytics (analytics.js), you’ll want to remove the line of code that doesn’t apply. I’ve included them both in the below code to illustrate the coding for each.
Credit for the actual print detection logic goes to TJ VanToll. Be sure to check out his great front end development blog. The code listens for either the window.onafterprint (if the browser supports it) or listens for the mediaQuery to switch to print.
If you are using Google Tag Manager, simply add this as a new tag to fire on all pages. I recommend loading it after the page has loaded (by adding a rule of ‘event’ equals ‘gtm.dom’). Below are the settings in Google Tag Manager (GTM):
Once you have this Google Analytics event tracking code in place, you should start to see the print activity data populate in the Event reports. Below is a sample output after you click into the ‘Print Intent’ event category. For example, you can see below that 1,964 people had the intent to print the about us page.
Interested in how to track other outbound/external link activity? Check out this related post on how to track downloads and other outbound tracking in Google Analytics.
Share this Post
Web Analytics Blog
We're here to help with tips and insight on the following topics:
Optimize your website and marketing campaigns