2016-07-30 181 views
0

我正在嘗試使用Google Analytics(分析)v4 Javascript API解決某個事件(通過事件操作)觸發的次數。我需要在過濾器部分放置什麼來獲取我要查找的號碼?這是我現在,它只是返回零:Google Analytics API Javascript v4事件跟蹤

// Call the Analytics Reporting API V4 batchGet method. 
     gapi.client.analyticsreporting.reports.batchGet({ 
      "reportRequests":[ 
      { 
      "viewId":VIEW_ID, 
      "dateRanges":[ 
       { 
       "startDate":"yesterday", 
       "endDate":"today" 
       }], 
      "metrics":[ 
       { 
       "expression":"ga:totalEvents" 
       }], 
      "dimensions": [{"name":"ga:eventLabel"}], 
      "dimensionFilterClauses": [ 
       { 
       "filters": [ 
        { 
        "dimensionName": "ga:eventLabel", 
        "operator": "EXACT", 
        "expressions": ["name-of-label"] 
        } 
       ] 
       } 
      ], 
      }] 

回答

0

您的要求似乎是正確的:

{ 
    "reportRequests": 
    [ 
    { 
     "viewId": "XXXX", 
     "dimensions": 
     [ 
     { 
      "name": "ga:eventLabel" 
     } 
     ], 
     "metrics": 
     [ 
     { 
      "expression": "ga:totalEvents" 
     } 
     ], 
     "dimensionFilterClauses": 
     [ 
     { 
      "filters": 
      [ 
      { 
       "operator": "EXACT", 
       "dimensionName": "ga:eventLabel", 
       "expressions": ["name-of-label"] 
      } 
      ] 
     } 
     ] 
    } 
    ] 
} 

執政所有的東西我會建議作出不過濾的要求,以確保您有全字符串name-of-label。如果你只有一個局部的字符串,然後使用不同的operator

  • BEGINS_WITH匹配與所提供的匹配表達式 開始值。
  • ENDS_WITH匹配以提供的匹配 表達式結尾的值。
  • PARTIAL子串匹配。
  • ...
相關問題