2017-04-04 198 views
0

不能跟踪下载的文件在谷歌Analytics(分析)

<script type="text/javascript"> 
 
\t function downloadCount(type){ 
 
\t \t var ajaxparameter="downloaded="+type; 
 
\t \t var xmlhttp=new XMLHttpRequest(); 
 
\t \t var glurl="logger.jsp"; 
 
\t \t xmlhttp.onreadystatechange=function() 
 
\t \t { 
 
\t \t if (xmlhttp.readyState==4 && xmlhttp.status==200) 
 
\t \t { 
 
\t \t } 
 
\t \t } 
 
\t \t xmlhttp.open("POST",glurl,true); 
 
\t \t xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
 
\t \t \t xmlhttp.send(ajaxparameter); 
 
\t } 
 
</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>

我想跟踪的文件名(这是被用户下载的),当他们点击链接。 正在跟踪页面视图,但下载事件未被跟踪,文件名没有被反映在GA控制台上

+0

你有没有实现的情况下对文件下载跟踪?如果是,请提供代码,以便我们帮助您 – Igneel64

+0

我已附上代码。请让我知道是否需要进行任何更改。 –

回答

0

从快速查看我不能检测到错误,但你应该仔细按照这个帖子How to call multiple JavaScript functions in onclick event?描述的一些模式。这将解除来自ga下载事件的Ajax调用。试试看

另外,&quot;意味着双引号(“)。因此,这将可能给你一个错误,请尝试用单引号(')将您的文件名。

+0

非常感谢。我会尝试在测试服务器上检查它。 –

+0

酷,测试它,如果没关系,请告知我 – Igneel64

+0

我按照您的建议进行了更改,但仍无法注册事件。我更新了代码以反映我的更改。 –

相关问题