You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用带例外的Regex配置GA URI搜索替换过滤器合并注册路径

Hey there, let's work through this Google Analytics filter setup to clean up your enrollment path tracking. I've got a tailored solution that'll merge all those messy variants into a single /enrollment path while excluding your thank-you pages—here's how to do it:

Solution Overview

Your goal is to collapse 4000+ enrollment-related path variants (like /enrollment, /enrollment/, /enrollment/sem01, etc.) into a unified /enrollment value, while excluding any thank-you pages that fall under the /enrollment namespace. We'll use a custom search-and-replace filter with a regex that includes an exclusion rule to make this happen.

Regex Configuration

Here's the exact regex and replacement value you'll need:

Search String (Regex)

^\/enrollment(?!\/thank-you)(\/.*)?$

Replace String

/enrollment

Adjusting the Exclusion Rule

If your thank-you page uses a different path (e.g., /enrollment/thanks, /enrollment/confirmation), modify the negative lookahead part to match. For multiple excluded paths, use a pipe | to separate them:

^\/enrollment(?!\/thank-you|\/thanks|\/confirmation)(\/.*)?$
Step-by-Step Filter Setup
  1. Log into your Google Analytics account and navigate to the custom view you created for this tracking.
  2. Click the Admin gear icon in the bottom-left corner.
  3. In the View column, select Filters.
  4. Click Add Filter to create a new filter.
  5. Give your filter a descriptive name (e.g., "Merge Enrollment Paths & Exclude Thank You").
  6. Under Filter Type, select Custom, then choose Search and Replace.
  7. From the Field A -> Extract A dropdown, select Request URI (for GA4, select Page path + query string instead).
  8. Paste the regex from above into the Search String field.
  9. Paste /enrollment into the Replace String field.
  10. Use the Filter Test section at the bottom to verify:
    • Input paths like /enrollment or /enrollment/sem01 should show a replacement value of /enrollment.
    • Input your thank-you page path (e.g., /enrollment/thank-you) should not be matched or replaced.
  11. Click Save to activate the filter.
Regex Breakdown

Let's break down the regex so you understand how it works:

  • ^\/enrollment: Matches any URI that starts with /enrollment (the ^ ensures we only match the start of the string, and \/ escapes the forward slash for regex syntax).
  • (?!\/thank-you): A negative lookahead that tells the regex to skip any path where /enrollment is immediately followed by /thank-you—this excludes your thank-you pages.
  • (\/.*)?: Matches any optional trailing content after /enrollment (including a trailing slash or SEM/UTM parameters). The ? makes this section optional, so it covers both /enrollment and /enrollment/ cases.

内容的提问来源于stack exchange,提问作者Eric Anderson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:26:40