Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server-side logging when someone prints a web page

Tags:

html

css

printing

At my work, we're interested in tracking how often people print our web pages. (If a lot of people are doing it, we'll probably put more focus on making the print view nicer.)

Obviously if we put a "Print" button on the page, we can log when people click on that, but if users just use the "File" menu and choose "Print," we have no way of knowing if they did that.

Is there some clever way to use print-only CSS to cause the browser to issue a web request only when printing? My experiments seem to say no, but this seems like it should be possible.

Edit: A reasonable answer is offered below that works in FF; I'm offering a 100 point bounty for a solution that works on IE as well.

like image 920
Dan Fabulich Avatar asked Dec 30 '22 22:12

Dan Fabulich


1 Answers

To build on responses from Tyson and Jao, you can try this approach to get around the issue of background images not being displayed/printed by default. instead of background image, use a bullet image...

Insert an element in your HTML source like:

<div id="print_tracker"><ul><li>&nbsp;</li></ul></div>

In your screen CSS:

@media screen {
    #print_tracker { display: none; }
}
@media print {
    #print_tracker { display: block; }
    #print_tracker UL { list-style-image: url(/images/printtracker.gif); }
}

Then track the hits to that image. Hacky... i know

like image 179
Roy Rico Avatar answered Feb 01 '23 11:02

Roy Rico