ขณะนี้หน้าที่คุณขอยังไม่พร้อมให้บริการในภาษาของคุณ คุณสามารถเลือกภาษาอื่นได้ที่ด้านล่างของหน้าหรือแปลหน้าเว็บใดๆ ให้อยู่ในภาษาที่คุณต้องการได้ทันที โดยใช้คุณลักษณะการแปลภาษาในตัวของ Google Chrome

[UA] Filters and segments

Developers supply filters and segments to Reporting API requests to get subsets of Analytics data. They often ask these questions:

  • What are the differences between filters and segments?
  • When to use filters and when to use segments?

The following sections answer these questions.

Differences between filters and segments

Consider the following three user sessions between time T1 and T2:

Using a segment to request a subset of Analytics data, the following query:

  Dimension: ga:pathPath (Pagepath)
  Metric: ga:pageviews (Pageviews)
  Segment: users::condition::ga:pagePath!=pathToPageB
 

produces this report:

         Page Pageviews
pathToPageA         1
 

For the specified segment, every user session is checked against the segment condition (ga:pagePath!=pathToPageB). For user sessions that meet the condition, all rows are returned; for user sessions that don't meet the condition, no rows are returned. Because segments operate at the session level, the pageview of Page A at session 2 is excluded because the session includes a pageview of Page B. 

Using a filter to request a subset of Analytics data, the following query:

  Dimension: ga:pathPath (Pagepath)
  Metric: ga:pageviews (Pageviews)
  Filter: ga:pagePath!=pathToPageB
 

produces this report:

        Page Pageviews
pathToPageA         2
 

For the specified filter, all rows of all sessions are examined; only the rows that meet the filter condition (ga:pagePath!=pathToPageB) are returned. Because filters operate at the hit level, the pageview of Page A at session 2 is included although the session includes a pageview of Page B. To a Reporting API request, Analytics returns data representing rows in a table. Filters and segments can be used together to get subsets of Analytics data:

  Dimensions: ga:country and ga:browser
  Metric: ga:pageviews
  Filter: ga:country==Canada
  Segment: users::condition::ga:browser==Chrome

When to use Filters and when to use Segments

The following are supported by segments only:

  • Sequences
  • In list operator []
  • Between (range) operator <>

For example:

  • Get users who used a Windows desktop and then a mobile Android device:
      users::sequence::ga:deviceCategory==desktop;
      ga:operatingSystem==Windows->>
      ga:deviceCategory==mobile;
      ga:operatingSystem==Android
    
  • Get sessions where the browser was Chrome, Firefox, or Opera:
      sessions::condition::ga:browser[]Chrome|Firefox|Opera
    
  • Get sessions in the hours 15 to 22:
      sessions::condition::ga:hour<>15_22
    

As another example, the following complex expression can be specified in a segment only:

  users::condition::perSession::ga:screenviews>5;
  sessions::condition::ga:adGroup=@aaa,
  ga:adTargetingType=@bbb;condition::
  ga:mobileInputSelector=@ccc;ga:campaign=@ddd
 

To get a specific hit (for example, ga:pageviews) from all sessions that match a condition, use a filter:

  filters=ga:pagePath=@analytis/devguides/reporting

ข้อมูลนี้มีประโยชน์ไหม

เราจะปรับปรุงได้อย่างไร

หากต้องการความช่วยเหลือเพิ่มเติม

ลองทำตามขั้นตอนต่อไปนี้

true
เลือกเส้นทางการเรียนรู้ของคุณเอง

โปรดไปที่ google.com/analytics/learn ซึ่งเป็นแหล่งข้อมูลใหม่ที่จะช่วยให้คุณได้รับประโยชน์สูงสุดจาก Google Analytics 4 เว็บไซต์ใหม่นี้มีทั้งวิดีโอ บทความ และขั้นตอนพร้อมคำแนะนำ รวมถึงลิงก์ไปยังแหล่งข้อมูลต่างๆ เกี่ยวกับ Google Analytics เช่น Discord, บล็อก, ช่อง YouTube ตลอดจนที่เก็บ GitHub

เริ่มเรียนรู้วันนี้เลย

Search
Clear search
Close search
Main menu
5411478565058236493
true
ค้นหาศูนย์ช่วยเหลือ
true
true
true
true
true
69256
false
false