FIltering realtime data by pathname with GA4 Data API
I am working on a realtime dashboard that would fetch data about active users from Google Analytics with Data API (GA4). The feature that I really need is filtering events by pathname.
So I would like to display users active in the last 30 minutes per page, so that I can see what pages are most popular in the last half hour.
I was working with the same API for non-realtime data and I was able to achieve that by passing a dimensionFilter
to the request. I found (after decided to use GA4) that there is a very limited subset of dimensions and metrics available and anything that I could use to filter events by page is not there.
I was also trying to implement custom event dimensions or metrics but that is not a thing for realtime data that supports only custom user properties.
I was not able to find any information on whether page dimensions or custom event support is going to be implemented or not for realtime requests. I hope that switching to UA (Universal Analytics) is not the only option because I will lose the current data that I collected with GA4.
Did anyone try to request realtime data that could be filtered by page attributes? It could be even a page title - anything that would allow me to understand what the user was actually viewing.
Page titles are available in realtime reports from the Google Analytics Data API (See "unifiedScreenName" on Realtime Dimensions & Metrics). Page paths are not available today.
This is an example realtime report request for "Views by Page title and screen name":
{
"dimensions": [
{
"name": "unifiedScreenName"
}
],
"metrics": [
{
"name": "screenPageViews"
}
]
}
This request will reproduce the "Views by Page title and screen name" card in the GA4 UI:
We'll work on getting page paths available in realtime reports in the future. Does this "Views by Page title and screen name" report work for your use case today?
Thanks,
Brett Sneed
The Google Analytics Team