开发者

Put Google Analytics code on a link?

How do you put google analytics code on a link, for example a link 开发者_如何学Pythonon your page to a download file. Is there a way to call the analytics function from a link?

Cheers.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜