I tried to retrieve all information about my website from GA (Google Analytics). I'm using laravel and this package https://github.com/spatie/laravel-analytics to make my life easier. However, that package requires "View ID" from GA, which I can't help myself to find it. I read this thread https://support.google.com/analytics/thread/15684521?hl=en and I'm guessing that since GA 4 they totally removed the views column from Web + App property (which will be created as a default) (correct me pls). Did anyone had this problem before? Where I can find that "view id"? are there some articles that can help me solve this problem? Any suggestion about better way to achieve my goal?
Asked
Active
Viewed 1.9k times
2 Answers
17
In GA4 there aren't Views so you if you want to use your code (who needs a View), you have to create a Universal Analytics Property.
You can find it by clicking on Show advanced options
(when you create a new property):

Michele Pisani
- 13,567
- 3
- 25
- 42
-
thank you so much. Finally found the view id. However I just realized the data latency took 24 hours long from the GA real time to finally fetched to my application. There's nothing I can do with this one. So I decided to use other services like Histat and override their widgets style. Thank you for answering a right answer. – Raden Kriting Oct 24 '20 at 20:20
-
I'm correcting my comment for those who read it. I was wrong about data latency. I already using histat, but then I feel kinda weird that the data latency took that long, so I decided to try GA once more. So long my die dump returning an empty array, after a couple minutes, it's magically showing the data, which in real-time. – Raden Kriting Oct 25 '20 at 17:58
-
1Thanks for the help. Is there a way to get this View ID after a new Analytics property was created? – Greg Oct 27 '20 at 16:11
-
1There are no views in GA4. – Michele Pisani Oct 27 '20 at 16:15
-
@Greg if your code forced you to use view id, then you should follow michele answer. – Raden Kriting Oct 29 '20 at 11:30
13
For anyone using GA4, you must use Google Analytics Data API instead of Reporting API. Use the same oauth scopes and you can use already issued token. This is the sample http request (post):
https://analyticsdata.googleapis.com/v1beta/properties/[property id]:runRealtimeReport
with example body:
{
"metrics": [{ "name": "activeUsers" }]
}
which gives you simple result. Keep in mind that metrics are different, there are now no totalUsers. Use this list which has all allowed metrics and you can find dimensions on the same page.

VityaSchel
- 579
- 7
- 18
-
Thank you so much! This is exactly what I needed after tinkering with the reports API to no avail for hours. – Boldewyn Apr 04 '23 at 11:36