Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用Google Analytics设置事件跟踪-我的方法中是否存在错误?_Jquery_Joomla_Google Analytics - Fatal编程技术网

Jquery 使用Google Analytics设置事件跟踪-我的方法中是否存在错误?

Jquery 使用Google Analytics设置事件跟踪-我的方法中是否存在错误?,jquery,joomla,google-analytics,Jquery,Joomla,Google Analytics,我有一个Joomla网站,通过 <script type="text/javascript">var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxx-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/

我有一个Joomla网站,通过

<script type="text/javascript">var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-xxxxxx-1']);
      _gaq.push(['_trackPageview']);

      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();

      </script>
var _gaq=_gaq | |[];
_gaq推送([''u设置帐户','UA-xxxxxx-1']);
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
在呈现下载链接的Joomla文件中,我有以下内容

<a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $attachment->link; ?>" onClick="_gaq.push(['_trackEvent', 'Downloads', 'Click', 'Downloads','0']);"><?php echo $attachment->title; ?></a>

这会产生URL,例如

<a title="file.pdf" href="/index.php/products/someproduct/item/download/60_7372007fc87f36b939ebed0ab3be8e65" onClick="_gaq.push(['_trackEvent', 'Downloads', 'Click', 'Downloads','0']);">Product</a>

但这项活动并不是在佐治亚州举办的。你看到有什么明显的问题吗?当用户转到页面并单击此链接时,会出现一个保存文件框,因此我知道url本身的格式很好,但似乎onclick事件没有反馈给GA,我无法找出我做错了什么

有人看到我的实现中有什么明显的错误吗?无论如何,jquery是加载的,但我真的无法想象这会导致问题


谢谢

您的最后一个参数是错误的-事件值应该是整数,而不是字符串,因此请丢失引号(值在任何情况下都是可选的,因此您根本不需要设置它)。谢谢,这似乎解决了问题!现在,如果我只能找出如何提取事件的地理信息…提取地理数据,就像在顶级事件报告中应用第二维度一样?或者将检测到的地理位置连同事件一起从服务器发送到GA?第二个选项。我想我明白了。我为事件类型创建了一个目标,现在在Geo->Location下我可以选择目标。但这不是一个非常方便的方法。理想情况下,我正在尝试为每次下载创建一个描述国家的报告。查看自定义维度-您应该将维度设置为您的自定义地理位置,然后发送事件。现在,在Top Events报告中,您可以添加自定义维度的第二维度。你也可以由此引发进球!您甚至可以在用户范围内应用自定义维度,这样他们采取的任何其他操作都将与该自定义地理位置相关联。希望有帮助!