Google Analytics URL 正则表达式代码

发布于 2024-12-13 10:18:46 字数 330 浏览 3 评论 0 原文

我正在为 Google Analytics 中动态的网站链接设置目标转化

https:// www.learningandthebrain.com/Online-Register/CONF-103/Submit

上面是动态链接的示例 这里 CONF- 后面的数字不断变化,我想为我的目标创建最终 URL

我必须输入正则表达式以匹配站点链接 Online-Register/CONF-103/Submit

I am setting goal conversion for my site links which are dynamic in Google Analytics

https://www.learningandthebrain.com/Online-Register/CONF-103/Submit

example of the dynamic links is above
here the number after CONF- keeps changing and I want to create final URL for my goal

I have to enter the regexp expression to match the site link Online-Register/CONF-103/Submit

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

残花月 2024-12-20 10:18:46

如果只有 CONF 之后的数字发生变化,类似这样的事情应该可以解决问题:

(.*)learningandthebrain\.com/Online-Register/CONF-(\d+)/Submit

这几乎是基本的,所以我建议您在空闲时间研究一下正则表达式。在学习正则表达式时,我发现这个工具不可或缺: http://gskinner.com/RegExr/ - 它允许您可以轻松检查您的正则表达式是否按预期工作。

编辑:
正则表达式不应包含域的www部分,因为这样它只会匹配来自该域的请求并忽略来自http://learningandthebrain.com。实际上,我非常确定甚至可以省略开头的“catch all”(.*) 表达式。

此外,谷歌分析不需要正斜杠转义。

If only the number after CONF changes, something like this should do the trick:

(.*)learningandthebrain\.com/Online-Register/CONF-(\d+)/Submit

This is pretty much as basic as it gets, so I would advice you to look into regular expressions in your free time. When learning regular expressions I have found this tool indispensable: http://gskinner.com/RegExr/ - it allows you to easily check if your regex works as expected.

Edit:
The regex should not include the www part of the domain, because then it will only match requests coming from it and ignore requests from http://learningandthebrain.com. Actually I am pretty sure that even the "catch all" (.*) expression at the beginning can be omitted.

Also, forward slash escaping is not required with google analytics.

凉风有信 2024-12-20 10:18:46

只是为了提高效率,完成 Crafty_Shadow 的正则表达式

https:\/\/www\.learningandthebrain.com\/Online-Register\/CONF-(\d+)\/Submit

(我知道这最好是一条评论,但我仍然没有等级来做到这一点)

Just for the sake of efficiency finish Crafty_Shadow's regex

https:\/\/www\.learningandthebrain.com\/Online-Register\/CONF-(\d+)\/Submit

(I know this would better be a comment but I still don't have the rank to do it)

[旋木] 2024-12-20 10:18:46

您应该使用以下正则表达式:

/Online-Register/CONF-(\d+)/Submit

请注意,该域不是 Page 属性的一部分,如果您将其包含在正则表达式中,则不会匹配。只需包含路径即可。

如果您使用的网络服务器(如 IIS)不区分大小写,我还会启用忽略大小写标志。

You should use the following regex:

/Online-Register/CONF-(\d+)/Submit

Note that the domain is not part of the Page attribute and won;t match if you include it in the regex. Just include the path.

I'd also enable the ignore case flag if you are using a webserver that makes no distinction between uppercase and lowercase like IIS.

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