aawnu / php-ga4

PHP Library for Google Analytics 4 with Server Side Tagging
The Unlicense
54 stars 9 forks source link

Tracking Full Server? #92

Closed manuelcoders closed 4 months ago

manuelcoders commented 4 months ago

HI, have you ever managed to track on GA4 without using the gtag.js part to get user identifiers?

I tried, but I can't see the complete data on GA4, perhaps because the session_start event cannot be sent via API.

I would like to do completely server tracking, do you think it's possible in some way?

aawnu commented 4 months ago

Full server-to-server

While it's possible to send events to Google Analytics solely with measurement protocol, only partial reporting may be available.

There are various sites out there that explains how the gtag events works, but some of the initial data is randomized. I was looking into this earlier, but decided that it was not worth the hassle. This is also why Event: PageView exists as deprecated. It works, but is not meant to be used this way.

I think the closes you will get is utilizing firebase or some sort of middleware-url (configurable in gtat), but not sure how this would be done properly.

manuelcoders commented 4 months ago

I'm very disappointed.

It would be very convenient for me to be able to do everything on the server side. I've done a lot of research but I've never found anyone who succeeds, probably because there are reserved events like session_start with can't be called server side.

aawnu commented 4 months ago

I'm sorry to dissapoint.

You can try to figure out how gtag calls the analytics server and run replicate those request from backend, but not sure how you would handle the cookies and stuff.

manuelcoders commented 4 months ago

Otherwise another idea could be to recreate the views by reading the data from bigquery with looker studio....

I'm working on it, thanks so much for the replies!