简体   繁体   English

Google Analytics网站搜索

[英]Google Analytics Site Search

I use following sample URL pattern to search pattern on my web site. 我使用以下示例URL模式来搜索我的网站上的模式。

http://www.mysite.com/search/ someword No query strings, just clean URL.. http://www.mysite.com/search/ someword没有查询字符串,只是干净的URL ..

How can set this URL to google analytics site search system? 如何将此URL设置为Google Analytics分析网站搜索系统?

In theory, you should be able to create a profile filter to convert the URLs to use a query string. 理论上,您应该能够创建一个配置文件过滤器来转换URL以使用查询字符串。 In practice, it turns out it's not possible, because Site Search gets processed before filters get processed. 实际上,事实证明这是不可能的,因为在过滤器处理之前会对Site Search进行处理。

Instead, what I've found that works is to just manipulate it in JavaScript so that you "fake" a query string directly from the browser. 相反,我发现有效的方法是在JavaScript中操作它,以便直接从浏览器“伪造”查询字符串。

Something like: 就像是:

if(!location.pathname.match(/^\/search/)){
    _gaq.push(["_trackPageview"]);
}
else{
    _gaq.push(["_trackPageview", location.pathname.replace("/search/","/search?q=")]);
}

This would "fake" a query string with a key of q that you could then easily use the Site Search feature with. 这将“伪造”具有q键的查询字符串,然后您可以轻松地使用“站点搜索”功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM