如何编写 Google Analytics 过滤器来记录网站搜索
我想用谷歌分析记录我所有的网站搜索,但问题是我的搜索链接看起来像这样
**www.mywebsite.com/search/category/your+query+here**
从我发现我必须给GA查询参数(mywebsite.com/search.php?q=your+query +此处)但我没有(并且不想要任何)。
有没有办法用谷歌分析过滤器重写URL?如果是的话怎么办。
I what to record all my website searches with google analytics but the problem is my search links look like this
**www.mywebsite.com/search/category/your+query+here**
From what i found out i must give GA the query parameter (mywebsite.com/search.php?q=your+query+here) but i have none (and don't want any).
Is there a way to rewrite the URL with a google analytics filter? If yes how.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您可以创建一个自定义过滤器,将 URL
/search//
重写为?q=&c=< /代码>。
转到分析设置 › 筛选器管理器,然后单击添加筛选器。在“过滤器类型”下拉列表中选择“自定义过滤器”,选择“搜索和替换”单选按钮,然后设置两个“请求 URI” /em> 具有相应值的字段。有关详细信息,请参阅“如何创建Google Analytics(分析)帮助中心的过滤器?'页面。
记住!由于无法重新处理过去的访客数据,因此请始终保留不应用过滤器的“原始”配置文件。有关更多详细信息,请参阅“过滤器和过滤器的最佳实践”一章。演示文稿“Google Analytics(分析)中的过滤器”中的个人资料。
Yes, you can create a custom filter that rewrites URL
/search/<category>/<query>
to?q=<query>&c=<category>
.Go to Analytics Settings › Filter Manager, and click Add Filter. Choose Custom Filter in the Filter Type drop-down list, select Search and Replace radio button, and then set two Request URI fields with the corresponding values. For further details, see ’How do I create a filter?’ page in Google Analytics Help Center.
Keep in mind! Since past visitor data cannot be reprocessed, always keep a ’raw’ profile that you do not apply filters against. For further details, see chapter ’Best Practices for Filters & Profiles’ in presentation ’Filters in Google Analytics’.
在应用过滤器之前处理站点搜索。
我经过一周的测试才意识到这一点。是的,过滤器逻辑是正确的,但从 2009 年 11 月 1 日起,这将不适用于网站搜索。
我们通过将 ?search= 参数附加到 GA 脚本中的页面 URI 来实现此目的。然后,我们在配置文件设置中删除搜索参数,并在内容部分中获取纯 URI 以及站点搜索中跟踪的搜索。
Site Search is processed BEFORE Filters are applied.
I went through a week of testing to realize this. Yes, the Filter logic is correct, but as of Nov 1, 2009 this will not work with Site Search.
We accomplished this by appeding the ?search= parameter to the page URI in the GA script. Then we strip search params in the Profile Settings and we get the pure URI's in the content section as well as the Searches tracked in Site Search.
我知道这已经过时了,但是为了扩展之前接受的答案,请在 _trackPageview 调用中使用“虚拟网址”,因此对于 www.mywebsite.com/search/category/your+query+here 有
这意味着网址将不会'不会改变,所以其他一切都有效(如前面的答案中所述) - 如果您确实想要,您可以删除搜索参数,但除非您遇到 URL 限制,否则我可能更愿意保留它们,以便它们可以在内容报告中看到。
I know this is old, but to expand on the prev accepted answer, use a 'virtual url' in the _trackPageview call, so for www.mywebsite.com/search/category/your+query+here have
This means that URLs won't be changed, so everything else works (as noted in the previous answer) - if you really want to you could remove the search params, but unless you're running into a URL limit I'd probably prefer to keep them present so they can be seen in the content reports.