Outbound Clicks未被Google Analytics追踪 [英] Outbound Clicks Not Being Tracked By Google Analytics

查看:138
本文介绍了Outbound Clicks未被Google Analytics追踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Google网站上的广告横幅上追踪Google Analytic的出站点击次数。



这样做的方式是,如果您登录,你看不到任何横幅。如果你没有登录,你会看到横幅。我已经在我的wordpress网站上使用以下代码成功完成了这项工作:

 <?php 
if(is_user_logged_in )){
回声没有广告 - 谢谢你支持我们;
}
else {
echo

< a href = \http://www.advertiser.org/\onClick = \ pageTracker._trackEvent('Outbound','CuteDog','300sb'); \target = \_blank\ = \nofollow \>< img src = \http ://www.mydomain.com/box/cp/cuteDog.gif\width = 300 height = 250 alt = \Cute Dog \style = \border:none; \/> < / a>

;
};
?>

现在,横幅广告和所有内容都可以正常使用,但不会被GA追踪。我确信我的onclick函数正确:

  onClick =pageTracker._trackEvent('Outbound','CuteDog', '300SB'); 

我的Google Analytics跟踪代码位于我的页面的标题中,并且是最新的代码:

 < script type =text / javascript> var _gaq = _gaq || []; 
_gaq.push(['_ setAccount','UA-8441420-2']);
_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 =文档.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga,s);
})();< / script>

我做错了什么?

解决方案

您正在使用两种不同版本的GA代码。这是您应该使用的异步版本:

  _gaq.push(['_ trackEvent','Outbound','CuteDog ','300sb']); 

你可以直接在你的onclick中或者使用包装函数来调用它。



编辑每个OP评论关于不理解如何操作

您把这一点的代码放在你的链接的onclick ...

改变这个:

 <$ ('Outbound','CuteDog','300sb'); \//www.advertiser.org/\onClick = \pageTracker._trackEvent target = \_blank\ = \nofollow \>< img src = \http://www.mydomain.com/box/cp/cuteDog.gif\width = 300 height = 250 alt = \Cute Dog \style = \border:none; \/>< / a> 

至此:

 < a href = \http://www.advertiser.org/\onClick = \_gaq.push(['_ trackEvent','Outbound','CuteDog',' 300sb']); \target = \_blank\rel = \nofollow \>< img src = \http://www.mydomain.com/box/cp/ cuteDog.gif\width = 300 height = 250 alt = \Cute Dog \style = \border:none; \/>< / a> 


I am trying to track the number of outbound clicks by Google Analytic on an advertisement banner on my website.

The way this works is, if you are logged in, you see no banner. If you are not logged in, you see the banner. I have successfully done this on my wordpress site using the following code:

    <?php
if (is_user_logged_in()){
    echo "No Ads - Thank You for Supporting Us";
}
else {
echo "

<a href=\"http://www.advertiser.org/\" onClick=\"pageTracker._trackEvent('Outbound', 'CuteDog', '300sb');\" target=\"_blank\" rel=\"nofollow\"><img src=\"http://www.mydomain.com/box/cp/cuteDog.gif\" width=300 height=250 alt=\"Cute Dog\" style=\"border:none;\" /></a>

";
};
?>

Now, the banner and everything works, but it is not being tracked by GA. I am quite sure I have the onclick function correct:

onClick="pageTracker._trackEvent('Outbound', 'CuteDog', '300sb');"

My GA tracking code is located in the header of my page, and it is the most latest code:

   <script type="text/javascript">var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-8441420-2']);
  _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> 

What is it that I'm doing wrong ???

解决方案

You are using two different versions of the GA code. Here is the async version which you should be using:

_gaq.push(['_trackEvent','Outbound', 'CuteDog', '300sb']);

You can put this directly in your onclick or make a wrapper function to call it.

edit per OP comment about not understanding what to do with this

You put this bit of code in your link's onclick...

Change this:

<a href=\"http://www.advertiser.org/\" onClick=\"pageTracker._trackEvent('Outbound', 'CuteDog', '300sb');\" target=\"_blank\" rel=\"nofollow\"><img src=\"http://www.mydomain.com/box/cp/cuteDog.gif\" width=300 height=250 alt=\"Cute Dog\" style=\"border:none;\" /></a>

To this:

<a href=\"http://www.advertiser.org/\" onClick=\"_gaq.push(['_trackEvent','Outbound', 'CuteDog', '300sb']);\" target=\"_blank\" rel=\"nofollow\"><img src=\"http://www.mydomain.com/box/cp/cuteDog.gif\" width=300 height=250 alt=\"Cute Dog\" style=\"border:none;\" /></a>

这篇关于Outbound Clicks未被Google Analytics追踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆