Anders
Anders

Reputation: 37

Get specific event count, Google Analytics 4 in Google Analytics Data API (GA4)

How can I get a specific event count ex. eventName "video_start" and "Form"

I get total event count with "metrics":[{"name":"eventCount"}], but want only two events

POST https://analyticsdata.googleapis.com/v1alpha:runReport BODY JSON:

{
"entity":{"propertyId":"IDIDID"},
"metrics":[{"name":"sessions"}],
"metrics":[{"name":"conversions"}],
"metrics":[{"name":"eventCount"}],
"dimensions":[{"name":"sessionDefaultChannelGrouping"}],
"dateRanges":[{"startDate":"2021-01-01","endDate":"today"}]
}

DOC: https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema

Upvotes: 2

Views: 4096

Answers (1)

Brett
Brett

Reputation: 1289

To only get a report on two events, you'll need to add a dimension filter for the specific events reference.

  "dimensionFilter": {
    "filter": {
      "fieldName": "eventName",
      "inListFilter": {
        "values": [
          "video_start",
          "Form"
        ]
      }
    }
  },

Upvotes: 1

Related Questions