views:

34

answers:

2

Hello there.

How do you put google analytics code on a link, for example a link on your page to a download file. Is there a way to call the analytics function from a link?

Cheers.

A: 

One option for you would be to create a download page that redirects to the file to be downloaded and includes a link manually download if it doesn't automatically start.

Google would be used to track the page rather than the file.

Ragoczy
+3  A: 

You can track the click of the link using the _trackPageview function like so:

<a href="/wherever/file.pdf" onclick="javascript: pageTracker._trackPageview('/wherever/file.pdf')">Download Now</a>

The page view will be associated with whatever you pass to the _trackPageview function (/wherever/file.pdf in this case).

Google documentation is here.

Sean Carpenter