Google Analytics URL 正则表达式代码
我正在为 Google Analytics 中动态的网站链接设置目标转化
https:// www.learningandthebrain.com/Online-Register/CONF-103/Submit
上面是动态链接的示例 这里 CONF- 后面的数字不断变化,我想为我的目标创建最终 URL
我必须输入正则表达式以匹配站点链接 Online-Register/CONF-103/Submit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果只有 CONF 之后的数字发生变化,类似这样的事情应该可以解决问题:
这几乎是基本的,所以我建议您在空闲时间研究一下正则表达式。在学习正则表达式时,我发现这个工具不可或缺: http://gskinner.com/RegExr/ - 它允许您可以轻松检查您的正则表达式是否按预期工作。
编辑:
正则表达式不应包含域的www部分,因为这样它只会匹配来自该域的请求并忽略来自http://learningandthebrain.com。实际上,我非常确定甚至可以省略开头的“catch all”(.*) 表达式。
此外,谷歌分析不需要正斜杠转义。
If only the number after CONF changes, something like this should do the trick:
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.
只是为了提高效率,完成 Crafty_Shadow 的正则表达式
(我知道这最好是一条评论,但我仍然没有等级来做到这一点)
Just for the sake of efficiency finish Crafty_Shadow's regex
(I know this would better be a comment but I still don't have the rank to do it)
您应该使用以下正则表达式:
请注意,该域不是 Page 属性的一部分,如果您将其包含在正则表达式中,则不会匹配。只需包含路径即可。
如果您使用的网络服务器(如 IIS)不区分大小写,我还会启用忽略大小写标志。
You should use the following regex:
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.