Tip: How do you set a Google Analytics Goal to direct to a PDF file?

by emily on January 13, 2009

What if you are establishing your Google Analytic Goals and your end result is not for a user to reach a specific web page, but instead to download a PDF file? How do you program the Google Analytics Goal? Can it be done?

Yes, it can. A Google Analytics Goal can be the downloading of a PDF, AVI or WMV file. This requires different progamming than the normal steps to set a web page as a Goal. It requires the placement of specific javascript on your file download link.

For example, to log every click on a particular link to www.mysite.com/files/whitepaper.pdf as a pageview for /downloads/whitepaper you would add the following attribute to the link’s <a> tag:

<a href="http://www.mysite.com/files/whitepaper.pdf" onClick="javascript: pageTracker._trackPageview(’/downloads/whitepaper’); ">

Read the full Google article here.

Previous post: Tip: HTML Form - How To Code States

Next post: Design by M2 is Now Online