How to Track When People Print Web Pages on Your Site How to

People often show interest to know the extent viewers print pages over your site, and the kind of pages those are mostly printed. However, Google Analytics can help you on this matter.

Print Webpages

Knowing which are getting printed is crucial:

The site with printer accessed doesn’t let you know that visitors are really going for print works. As a site owner you would always love to know every action that is performed at the page. Some one is printing a particular page indicates that he is having some interest in it, and you as a site owner would always love to know about it.

Conventional ways of prints:

There are several ways of printing a web page. You may go with the conventional way of printing through File menu, or use keyboard shortcuts like Ctrl+P to let the page get printed. Normally, for better convenience designers keep a specialised Print button.

Well, through the help of Google Analytics you can easily know details about your print works over a site no matter in which way the visitor prints the page.

Getting all through Google Analytics

To do the job we have to include a secret 1 x 1 tracking picture to printed edition of the site. Now, as a viewer goes for printing the page (no matter in which way), the tracking snap downloads to the system and the print action is captured to your Google Analytics.

It’s quite an easy task to perform actually. You just need to put the code within the website template. For the WordPress users, they can put the code in footer.php file. It is here to mention that you have to exchange UA-1234-56 through the actual Google Analytics Profile ID.

The code is given below.

</script>

var googleAccountID = “UA-1234-56”;

function s4() {

return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);

}

function guid() {

return s4() + s4() + ‘-‘ + s4() + ‘-‘ + s4() + ‘-‘ + s4() + ‘-‘ + s4() + s4() + s4();

}

(function(){

var GIF = “https://ssl.google-analytics.com/collect?v=1&t=event” +

“&ec=print&tid=” + googleAccountID + “&cid=” + guid() +

“&z=” + (Math.round((new Date()).getTime() / 1000)).toString() +

“&ea=” + encodeURIComponent(document.title) +

“&el=” + encodeURIComponent(document.location.pathname);

var rule = “body:after{content:url(” + GIF + “)}”;

var head = document.head || document.getElementsByTagName(‘head’)[0];

var css  = document.createElement(‘style’);

if (css && head) {

css.setAttribute(“type”,  “text/css”);

css.setAttribute(“media”, “print”);

if (css.styleSheet) { // For IE

css.styleSheet.cssText = rule;

}

else

{

css.appendChild(document.createTextNode(rule));

}

head.appendChild(css);

/* Written by Amit Agarwal – labnol.org */

}

})();

</script>

After you put the code over your site, you have to enter inside the Google Analytics dashboard. Move to Real Time, then Events, and next go for Print option for event. However, if it is old report, you have to move to Behavior, and then Events report.

How Print Tracking with Analytics Works?

<style type=”text/css” media=”print”>

body:after

{

content:url(GOOGLE_ANALYTICS_TRACKING_IMAGE);

}

</style>

The above CSS along the given code do the trick. It inserts the Google Analytics invisible image over the site, though it only activates the moment when the style sheet is made functional.

The above way can do the job for PDF prints as well.

How to Track When People Print Web Pages on Your Site
0 votes, 0.00 avg. rating (0% score)

About Author

Paul Estrada

I'm a software engineer and tech enthusiast. Here at ClibTech I cover various of topics related to technology, internet and social media.

    Leave a Reply