title: Tracking Google Analytics on ASP.NET Image
body: <p>I need to track events for Google Analytics everytime someone downloads a document and have placed code in my asp:Image to do this but am not getting any realtime results. I've also tried placing the onclick on the asp:Hyperlink that surrounds the image, but it wasn't working that way either. </p>
  
  <p>Here is the code from the ItemTemplate of the repeater that the images are located in.</p>
  
  <pre><code>&lt;ItemTemplate&gt;
       &lt;asp:HyperLink runat="server" ID="FormHyperLink"  &gt;
          &lt;asp:Image runat="server" ID="FormImage" OnClick="_gaq.push(['_trackEvent', 'Downloads', 'Document']);" /&gt;
       &lt;/asp:HyperLink&gt;
  &lt;/ItemTemplate&gt;
  </code></pre>
  
  <p>In Google Analytics, I have the goal set up as Category : Downloads, Action: Document. 
  I can't specify one document that's getting downloaded since this is a repeater of images that when clicked on, download different documents. </p>
  
  <p>Can someone help me try to figure out how to get these downloads tracked correctly? I can't really change the code because this site is getting used by hundreds of people internally and even more outside of our company.</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT:
  Here's the entire repeater code:</p>
  
  <pre><code>&lt;asp:Repeater runat="server" ID="FormRepeater"&gt;
        &lt;ItemTemplate&gt;
            &lt;tr class="even"&gt;
              &lt;td width="475"&gt;&lt;%# Server.HtmlEncode(((Core.Domain.FormsLibrary.Form)Container.DataItem).Title) %&gt;&lt;/td&gt;
              &lt;td&gt;
                &lt;asp:Repeater runat="server" ID="FileRepeater" OnItemDataBound="Files_ItemDataBound" DataSource='&lt;%# ((Core.Domain.FormsLibrary.Form)Container.DataItem).Files %&gt;'&gt;
                &lt;ItemTemplate&gt;
                   &lt;asp:HyperLink runat="server" ID="FormHyperLink"  &gt;
                      &lt;asp:Image runat="server" ID="FormImage" OnClick="_gaq.push(['_trackEvent', 'Downloads', 'Document']);" /&gt;
                   &lt;/asp:HyperLink&gt;
                &lt;/ItemTemplate&gt;
                &lt;/asp:Repeater&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;asp:PlaceHolder runat="server" ID="DescriptionPlaceHolder" Visible='&lt;%# !String.IsNullOrEmpty(((Core.Domain.FormsLibrary.Form)Container.DataItem).Description) %&gt;'&gt;
            &lt;tr class="even"&gt;
              &lt;td colspan="2"&gt;&lt;%# Server.HtmlEncode(((Core.Domain.FormsLibrary.Form)Container.DataItem).Description) %&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;/asp:PlaceHolder&gt;
          &lt;/ItemTemplate&gt;
          &lt;AlternatingItemTemplate&gt;
            &lt;tr class="odd"&gt;
              &lt;td&gt;&lt;%# Server.HtmlEncode(((Core.Domain.FormsLibrary.Form)Container.DataItem).Title) %&gt;&lt;/td&gt;
              &lt;td&gt;
              &lt;asp:Repeater runat="server" ID="FileRepeater" OnItemDataBound="Files_ItemDataBound" DataSource='&lt;%# ((Core.Domain.FormsLibrary.Form)Container.DataItem).Files %&gt;'&gt;
                  &lt;ItemTemplate&gt;
                     &lt;asp:HyperLink runat="server" ID="FormHyperLink" &gt;
                        &lt;asp:Image runat="server" ID="FormImage" OnClick="_gaq.push(['_trackEvent', 'Downloads', 'Document']);" /&gt;
                     &lt;/asp:HyperLink&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:Repeater&gt;
              &lt;/td&gt;
            &lt;/tr&gt;
            &lt;asp:PlaceHolder runat="server" ID="DescriptionPlaceHolder" Visible='&lt;%# !String.IsNullOrEmpty(((Core.Domain.FormsLibrary.Form)Container.DataItem).Description) %&gt;'&gt;
            &lt;tr class="odd"&gt;
             &lt;td colspan="2"&gt;&lt;%# Server.HtmlEncode(((Core.Domain.FormsLibrary.Form)Container.DataItem).Description) %&gt;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;/asp:PlaceHolder&gt;
          &lt;/AlternatingItemTemplate&gt;
   &lt;/asp:Repeater&gt;
  </code></pre>