简体   繁体   中英

Custom Reports Metrics name in GOOGLE analytics

I have some custom reports in GA, I need to get them through API .

  reportRequests: [
      {
        viewId: VIEW_ID,
        dateRanges: [
          {
            startDate: '7daysAgo',
            endDate: 'today'
          }
        ],
        metrics: [
        {"expression": "ga:hOg8OmowQCyxAarL0pWvWg"},
        {"expression": "ga:sessions"}
        ]
      }

Where can I find expression for my custom?

I have tried with some Ids like ga:hOg8OmowQCyxAarL0pWvWg , but they all give me this error:

"Unknown metric(s): ga:hOg8OmowQCyxAarL0pWvWg For details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets ."

if you are trying to access Custom metrics use 'ga:metricXX' where you replace XX by the metric index so it should be ga:metric01 or ga:metric02...etc

to find custom metric index: 1. Click Admin, and navigate to the property to which you want to add custom metrics. 2. In the PROPERTY column, click Custom Definitions > Custom Metrics.

In order to request data from the google analytics reporting api you must send valid dimensions and metrics you can see the list of valid dimensions and metrics here Dimensions & Metrics Explorer

"Unknown metric(s): ga:hOg8OmowQCyxAarL0pWvWg For details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets ."

Means that the metric you are requesting (ga:hOg8OmowQCyxAarL0pWvWg) is not one of the allowed metrics on the list.

You cant request custom reports via the API your going to have to build the report using the metadata available to the api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM