How can I apply two (2) 'onclick' events to a single link?
Posted on 2009-12-17
Experts this is a two part question:
1. I need to figure out how to use two onclick events in the same link code.
2. I need to insert php coding inside the second onclick event which gives each link a unique name that can be tracked using Google Analytics.
I use php to dynamically create file links on my page. Here is an example link:
<a href="'.$getinfo['FilePath'].'" title="'.$getinfo['File'].'" onclick="return confirm("Notice: You are about to view privileged information.)">
The code above creates a link using the 'FilePath' stored in the database which leads to an Excell file. It also gives each link a unique title by using the value of 'File' stored in the database. On clicking this link it also creates a popup window which states "Note: You are about to view privileged information."
How can I add a second onclick event which adds the ability for Google Analytics to be able to track the clicking of this file link. Google Analytics says to use the following onclick event example to do so:
I think this may be an easy question but, I just wanted to make sure I provide the information necessary to answer it.