如何编写 Google Analytics 过滤器来记录网站搜索

发布于 2024-08-03 02:21:32 字数 255 浏览 2 评论 0原文

我想用谷歌分析记录我所有的网站搜索,但问题是我的搜索链接看起来像这样

**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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

横笛休吹塞上声 2024-08-10 02:21:32

是的,您可以创建一个自定义过滤器,将 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’.

<逆流佳人身旁 2024-08-10 02:21:32

在应用过滤器之前处理站点搜索。

我经过一周的测试才意识到这一点。是的,过滤器逻辑是正确的,但从 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.

甜扑 2024-08-10 02:21:32

我知道这已经过时了,但是为了扩展之前接受的答案,请在 _trackPageview 调用中使用“虚拟网址”,因此对于 www.mywebsite.com/search/category/your+query+here 有

gat._trackPageview( "/search/content/your+query+here?query=your+query+here&cat=category" )

这意味着网址将不会'不会改变,所以其他一切都有效(如前面的答案中所述) - 如果您确实想要,您可以删除搜索参数,但除非您遇到 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

gat._trackPageview( "/search/content/your+query+here?query=your+query+here&cat=category" )

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文