getButterfly Logo getButterfly code wrangling since 2005

Sometimes, it happens for a client to have a massive campaign and publish 200 PDF files. Or DOC files. Or ZIP files.

Sometimes, the client wants to count how many PDF files have been downloaded. This can be done in two ways. Either use a redirection function or intercept the click. For a high traffic website, redirections may be expensive. For future compatibility, redirections may be a bad idea. For forwards compatibility, downloads should reference direct file paths. It also helps with search engines, especially for PDF files. You should know that Google would extract the direct link from a redirection and index the direct path. Why not make its job easier and create direct links?

Using direct links creates a challenge, as the user will leave the page and there’s no way to record a click. Well, there is one, and this is what Counter Clicker plugin for WordPress does. It intercepts clicks on links using jQuery, it prevents browser’s default behaviour, it records the click and then resumes the link opening function. As jQuery is native to WordPress, there is no CPU cost and interception works with all kinds of elements, selectors and already existing plugins (such as lightboxes).

Using Clicker Counter, you can intercept direct file extensions (such as clicks on PDF links, DOC links, ZIP links), classes, relationships (such as lightboxes or modal popups) and custom selectors (IDs, elements, paragraphs, sections and more).

I would advise against using a general selector, such as “a” or “p”, as the plugin would record too many clicks.

This is what PDF statistics look like:

Clicker Counter - Raw Statistics

You can optimize your page accordingly and make the top links larger, bolder, place more content alongside them (such as ads) and you can have a general idea of what content is the most interesting on your web site.

My client is very happy and Clicker Counter may help you with your next project!
Get it from CodeCanyon!

Subscribe to getButterfly Blog

Once a week or so we send an email with our best content. We never bug you, we just send you our latest piece of content.

If you found any value in this post, agree, disagree, or have anything to add - please do. I use comments as my #1 signal for what to write about. Read our comment policy before commenting! Comments such as "Thank you!", "Awesome!", "You're the man!" are either marked as spam or stripped from URL.

Leave a reply

Love programming?

Learn about the most amazing things. Get smarter everyday!