【问题标题】:Matching my goal url in Google Analytics with regex将我在 Google Analytics 中的目标网址与正则表达式匹配
【发布时间】:2014-04-18 02:42:49
【问题描述】:

我想在谷歌分析中设置用户注册为目标,但是注册后的着陆页不一样,所以我会添加一个参数,比如registration_completed=true

在 Google Analytics(分析)网址匹配中使用的正确正则表达式是什么?

所以它应该在它之前包含registration_completed=true和?&,在它之后包含&#或什么都没有。

/registration-completed.html?registration_completed=true
/registration-completed.html?registration_completed=true&message=welcome
/registration-completed.html?message=welcome&registration_completed=true
/registration-completed.html?message=welcome&registration_completed=true#some-anchor

用户也会登陆registraton-completed.html以外的其他页面,否则我只会使用该网址进行跟踪。

【问题讨论】:

    标签: javascript php regex google-analytics


    【解决方案1】:

    试试这个:

    ^/registration-completed\.html\?([\w&=]*)registration_completed=true([\w&=]*)#?(.*)$
    

    用正则表达式测试 - http://regexr.com?38gl4

    编辑

    匹配任何页面

    ^(.*)\?([\w&=]*)registration_completed=true([\w&=]*)#?(.*)$
    

    新的正则表达式 - http://regexr.com?38h71

    【讨论】:

    • 也许我测试不正确,但它与/contact.html?registration_completed=true 之类的不匹配,第一个网址(例如contact.html)可以是任何东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-14
    • 1970-01-01
    • 2013-01-29
    相关资源
    最近更新 更多