Skip to content

Commit 1f2720c

Browse files
committed
Add debug section to readme
1 parent efb75e8 commit 1f2720c

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ composer require alexwestergaard/php-ga4
3232
- [Frontend](#frontend)
3333
- [Backend](#backend)
3434
- [Custom Events](#custom-events)
35+
- [Debug](#debug)
3536
- [Documentation](#documentation)
3637

3738
## GDPR Notice
@@ -305,6 +306,39 @@ class ExampleEvent extends AlexWestergaard\PhpGa4\Helper\EventHelper
305306
}
306307
```
307308

309+
## Debug
310+
311+
Measurement protocol for GA4 has a debug functionality that can be enabled with the `debug` parameter in the constructor.
312+
313+
```php
314+
$analytics = Analytics::new(
315+
measurement_id: 'G-XXXXXXXX',
316+
api_secret: 'xYzzX_xYzzXzxyZxX',
317+
debug: true
318+
);
319+
```
320+
321+
Once set, events are sent to `https://www.google-analytics.com/debug/mp/collect` which will return a validation response such as
322+
323+
```json
324+
{
325+
"validationMessages": [
326+
{
327+
"fieldPath": "events",
328+
"description": "Event at index: [0] has invalid name [_badEventName]. Names must start with an alphabetic character.",
329+
"validationCode": "NAME_INVALID"
330+
}
331+
]
332+
}
333+
```
334+
335+
This library already validates that events are properly formatted and it is unlikely, you will experience any validation messages.
336+
337+
Two important points:
338+
339+
- Events sent to the Validation Server will not show up in reports.
340+
- There is no way for events sent through measurement protocol to show up in the `debugView` in Google Analytics Admin.
341+
308342
## Documentation
309343

310344
- [Measurement Protocol](https://developers.google.com/analytics/devguides/collection/protocol/ga4)

0 commit comments

Comments
 (0)