javascript - 如何更好地跟踪 Google Analytics 中的 Google 图片搜索流量? [具体关键词]

标签 javascript google-analytics

所以我运行 HotelsFirst.com最近看到了一堆谷歌图片搜索流量 http://screensnapr.com/v/Rm1KdJ.png -- 问题是我无法找到人们为了访问我的网站所做的搜索。有很多不同的着陆页,所以一定有很多东西。我在 http://www.google.com/support/forum/p/Google+Analytics/thread?tid=4f166221a4857871&hl=en 找到了一些似乎有用的东西但是我使用的是不同版本的 Google Analytics,所以它对我不起作用。我的 javascript 代码是:

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

最佳答案

尚未对其进行测试(因为我手头没有任何链接到 Google 图片中的页面),但这就是您链接到的脚本将如何适应您的代码段。

<script type="text/javascript">
/* <![CDATA[ */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-19201482-3']);

var ref = document.referrer;
if (ref.search(/images.google/) != -1 && ref.search(/prev/) != -1) {
    var regex = new RegExp("images.google.([^\/]+).*&prev=([^&]+)");
    var match = regex.exec(ref);
    _gaq.push(['_clearOrganic']);
    _gaq.push(['_addOrganic',"images.google."+ match[1],"q"]);
    _gaq.push(['_setReferrerOverride', "http://images.google." + match[1] + unescape(match[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>

关于javascript - 如何更好地跟踪 Google Analytics 中的 Google 图片搜索流量? [具体关键词],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4606739/

相关文章:

javascript - JQuery 在按钮前隐藏/显示 Div

Firebase - 从服务器端云功能记录事件

javascript - 如何使用 body onload 事件动态包含页面中的所有脚本

google-analytics - 计算 BigQuery 中的谷歌分析独特事件

android - 使用 google-services.json 时的 autoActivityTracking

ios - Firebase iOS 调试控制台未记录任何内容

android - Google Analytics V4 离线事件跟踪

javascript - 使用 React JSX 设置的可选属性

javascript - 复制数组上的拼接会从父/主数组中删除对象

javascript - Node.js 错误处理设置未按预期工作