aawnu / php-ga4

PHP Wrapper for Google Analytics 4 with Server Side Tracking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable debug_mode support?

mattinglot opened this issue · comments

This is a really nice library, thank you for building it. One thing I noticed is I couldn't find a way to enable debug_mode in events (not to be confused with the debug url).

This is supposed to allow measurement protocol events to show up in the "Debug View" in the Admin Console, making it easier to see in real-time if the right stuff is getting into Analytics.

If this is somehow supported and I just missed it please let me know. Otherwise it would be a cool setting to see added.

Hello @mattinglot

Thank you for the kind words!

I might be missing a section of the developer documentation; I do not see anything about debug mode in the events api. Perhaps this is meant for the Javascript/GTM integration?

If you have any source or documentation then I can look further into this.

@aawnu supposedly it does support it, here's a link:
https://stackoverflow.com/questions/65094010/setting-debug-mode-with-measurement-protocol-ga4

The advantage would be that you can then see events instantly in the debug view and know they work vs waiting a day.

@mattinglot thank you for the link.

From the link you have sent I already have debug mode, for the entirety of requests with the debug variable when instanciating the Analytucs model. ref: https://github.com/aawnu/php-ga4/blob/master/src/Analytics.php#L32

Is it the individual "per event" debug you are looking for, that can work within the live/active code?

@aawnu yes I tried that but as far as I can tell it doesn't do the same thing. That's a separate debug feature of the measurement protocol that sends requests to a different endpoint and does not log them at all. The per-event debug_mode is an entirely different feature from the looks of it, which allows an event to be sent to the live endpoint, and appear within the GA 4 debug tool.

@mattinglot Roger, thank you for clarifying. I will have a look into it 🥳

@mattinglot I have pushed to master, would you be so kind and check if it works before I make a release?

Version dev-master should have the code included.

@aawnu Hmm so I was able to call ->debug(true) on an event, but I'm not seeing any debug events pop up in GA 4. Did they pop up in yours?

Not sure if the problem is the library or I'm doing something wrong.

@mattinglot Could you try step 6 here and see if something is misconfigured by your end?

@aawnu tried it including clicking dropdown and nothing. It's weird because it looks like the request is being sent by your code:

image

204 response is received.

The article does say it may take a day to start working so will try again tomorrow.

@mattinglot I will await further info from you then.

@aawnu hey Alex does it work for you? Unfortunately no change today. Did catch a bug where on localhost our code wasn't getting the client id from the cookie correctly and was using "session_id" instead, but fixing that seems to have made no difference.

Hello @mattinglot

I have not been at a computer during christmas, sorry for the delay! I do not get the data in and also no indication of what could be configured wrong. I am not sure if it is a bug with GA4 self.

I will not put much effort into this matter unless there is a clear need for it or documentation that explains it properly on the source documentation (referred last in readme).

If any news pop up please feel free to open another issue regarding this. I will keep the last addition in case its just a flaw inside GA4 self.