Add Google Analytics tracking to a link
<p>@Philip gave us this code snippet for adding to a link, to hook up with Google Analytics tracking.</p>

<pre><code>onclick="_gaq.push(['_trackEvent', 'Event Name', 'click', 'Button title/name']);"
</code></pre>

<p>Our actual code for outputted ads ( on our site , self served ads ) is yanked in using php and mysql. But the output of the ad is as follow.</p>

<pre><code> echo "&lt;a href=\"" . $url . "\"&gt;&lt;img src=\"" . $row['Image'] . "\" alt=\"" . $row['Caption'] . "\" title=\"" . $row['Caption'] . "\" /&gt;&lt;/a&gt;";
</code></pre>

<p>How would I combine both code snippets above, so that I can add the onclick event tracking to the secondary snippet.</p>

<p>Cheers</p>

<hr>

<p>Essentially at the moment we track in our own db clicks and impressions. We would like to obviously represent as much data about the ad itself ( not the page ) using some form of analytics.</p>

<p>The id for an ad is displayed as such</p>

<pre><code>$url = "http://www.ourdomain.com/adserver.php?Clicked=" . $row['ID'];
</code></pre>

<p>So seemingly into the GA onclick( we would need to parse the same ID ) if thats correct. Im going round in circles here.</p>
