Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get View ID from Google Analytics 4?

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?

like image 737
Raden Kriting Avatar asked Oct 24 '20 06:10

Raden Kriting


People also ask

Where do I find my Google view ID?

You find the view id when you go to the admin section and look at the outer right column (which is labelled "views"). Select the view you want to query from the dropdown and go to "view settings", there you find the id.

Are there views in Google Analytics 4?

Since Google Analytics 4 properties do not include views, user access and permissions are handled at the account and property levels. Conversion events are defined for the property, whereas in Universal Analytics, goals are defined at the view level.

What is User-ID in GA4?

A customer-generated ID used to differentiate between users and unify user events in reporting and exploration.


2 Answers

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):

enter image description here

like image 145
Michele Pisani Avatar answered Oct 17 '22 02:10

Michele Pisani


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.

like image 20
VityaSchel Avatar answered Oct 17 '22 02:10

VityaSchel