You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于Google Analytics API V4 v1Beta版本runRealtimeReport接口无法获取source、medium及url的技术问询

Alright, let's tackle your three questions about transitioning from the v3 real-time API to GA4's runRealtimeReport endpoint:

1. Retrieving Page URL, Source, and Medium with runRealtimeReport

Good news—you absolutely can get these fields via the v4 API, you just need to use the GA4-specific dimension names (they’re mapped differently than the v3 endpoint):

  • Access URL: Use pageLocation for the full, complete URL (including protocol and domain) or pagePath if you only need the path portion (like /blog/post).
  • Source & Medium: Grab sessionSource (this matches the v3 source field, e.g., google.com) and sessionMedium (matches v3 medium, e.g., referral). These are session-level dimensions, which lines up with the real-time session context you got from v3.

Here’s a quick example of what your request body might look like (REST API format) to pull these dimensions along with active users:

{
  "dimensions": [
    {"name": "pageLocation"},
    {"name": "sessionSource"},
    {"name": "sessionMedium"}
  ],
  "metrics": [
    {"name": "activeUsers"}
  ],
  "limit": 1000
}

If you need that relative timestamp (like v3’s minutesAgo), use the eventTimestamp dimension (it returns a Unix timestamp in microseconds) and calculate the difference from the current time to get minutes since the event occurred.

2. Feature Roadmap if This Isn’t Working for You

As of right now, the dimensions I listed are fully supported in runRealtimeReport—so you shouldn’t have to wait for a future release. If you’re hitting roadblocks, double-check a couple things:

  • Make sure your GA4 property is collecting the necessary events (like page_view, which is what populates the page and session dimensions).
  • Verify you’re using the exact dimension names I mentioned—GA4 has stricter naming conventions than v3, so typos or wrong names will cause missing data.

If there’s a specific edge case or field you’re missing that isn’t covered here, Google shares roadmap updates via their official Analytics developer communications. But for these core fields, they’re already live and ready to use.

3. Deprecation Date for the v3-beta Realtime Endpoint

Google hasn’t announced an exact shutdown date for the v3-beta realtime API yet, but their standard policy is to give at least 6 months’ notice before deprecating an API version. That said, v3 has been in maintenance mode for a while now—no new features are being added, and bug fixes are limited.

To avoid any unexpected disruptions, it’s best to prioritize migrating to the v4 API as soon as you can. Keep an eye on Google’s official developer announcements for any updates on the deprecation timeline.


内容的提问来源于stack exchange,提问作者Martijn de Bie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 06:39:11