Page 1 of 1

Using hash tag for null link [Solved]

Posted: Tue Sep 17, 2013 3:40 pm
by douglas1438
Hi all,

I've looked through the forum but can't find a definitive answer. Our SEO guy has asked me to add some code to PDF links so he can track the clicks on them.

My problem is the code requires a null link and onClick event which I can't make work, my current code opens the page in a new window and not the PDF.

Code: Select all

<a href="/{$page_alias}#" target="_blank" {literal}onclick="_gaq.push(['_trackEvent', 'Downloads', 'PDF', 'uploads/PDFs/document.pdf']);"{/literal}>
Thanks in advance for any help.

Re: Using hash tag for null link

Posted: Fri Sep 20, 2013 12:13 pm
by douglas1438
Found my own solution on Google Analytics help pages. Basically had missed 'javascript:' from front of tracking code.

Code: Select all

<a onclick="javascript:_gaq.push(['_trackEvent', 'tag1', 'tag2', 'uploads/PDFs/document.pdf']);" href="uploads/PDFs/document.pdf" target="_blank">download</a>