0

<script type="text/javascript">
 function downloadCount(type){
  var ajaxparameter="downloaded="+type;
  var xmlhttp=new XMLHttpRequest();
  var glurl="logger.jsp";
  xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
  {
  }
  } 
  xmlhttp.open("POST",glurl,true);
  xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
   xmlhttp.send(ajaxparameter);
 }
</script>
<td>
    <a class="dnld" onclick="function handleDownloadLinks(event) 
     {
       ga('send', 'event', 'Download', 'Click', 'ForwardIC_4.0.war');
     };
                                downloadCount(&quot;ForwardIC_4.0.war&quot;);"

                                              href="https://example.com/pub/infocenter/Forward/Release4.0/ForwardIC_4.0.war">

<img src="images/download.gif" alt="Download" border="0" style="margin-right:3px">Download</a>
 </td>

I am trying to track the file names(which are being downloaded by the user) when they click on link. The page view is being tracked but the download event is not being tracked,i.e. the file name is not being reflected the GA console

1 Answers1

0

From a quick look I can't detect something wrong but you should carefully follow some patterns described in this post How to call multiple JavaScript functions in onclick event? . That will decouple the Ajax call from the ga download event. Give it a try

Also the &quot; means double quotes("). So it will probably give you an error. Try adding your filename with single quotes (').

Community
  • 1
  • 1
Igneel64
  • 618
  • 4
  • 10