You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -22,7 +24,7 @@ The European Union have notified that Google Analytics does not comply with GDPR
22
24
23
25
Setup requires a **Measurement ID** and **API Secret**. Go to Administrator (Bottom left) -> Account -> Data Streams -> {Your Stream}. Here you should find Measurement ID at top and "Api Secrets for Measurement Protocol" a little down the page, where you can create yourself an `API secret`.
24
26
25
-
Go to `Administrator` (bottom left) and then select your `Account` -> `Data Streams` -> your stream.
27
+
Go to `Administrator` (bottom left) and then select your `Account` -> `Data Streams` -> your stream.
26
28
Here you will find `Measurement-ID` at top from and further down `Api Secrets for Measurement Protocol`, in there you can create yourself an `API Secret`.
27
29
28
30
Once you have obtained the credentials, you can initialise the Analytics like this:
@@ -47,7 +49,7 @@ Server Side Tagging is not supposed to replace the frontend Client and session i
47
49
4. Server uses `_ga` (or `_gid`) to send/populate events
48
50
- Eg. GenerateLead, Purchase, Refund and other backend handled events.
49
51
50
-
Note: It is entirely possible to push events to backend without acquiring the session cookies from Google Analytics; you will, however, lose information bundled inside the `GTAG.js` request if you do not figure out how to push that via backend too. You can replace the `_ga` and `_gid` sessions with your own uniquely generated id.
52
+
Note: It is entirely possible to push events to backend without acquiring the session cookies from Google Analytics; you will, however, lose information bundled inside the `gtag.js` request if you do not figure out how to push that via backend too. You can replace the `_ga` and `_gid` sessions with your own uniquely generated id.
51
53
52
54
All requests should follow this structure and contain at least 1 event for Google Analytics to accept it.
This library is built for backend server side tracking, but you will probably trigger most events through frontend with Javascript or Websockets. There will be 2 examples, one as pure backend for logged/queued events and one for frontend to backend communication.
137
+
This library is built for backend server side tracking, but you will probably trigger most events through frontend with Javascript or Websockets.
138
+
There will be 2 examples, one as pure backend for logged/queued events and one for frontend to backend communication.
136
139
137
140
### Logging / Queue
138
141
139
142
```php
143
+
// require vendor/autoload.php
144
+
140
145
use AlexWestergaard\PhpGa4\Exception;
141
146
use AlexWestergaard\PhpGa4\Analytics;
142
147
use AlexWestergaard\PhpGa4\Event;
143
148
use AlexWestergaard\PhpGa4\Item;
144
149
145
-
// require vendor/autoload.php
146
-
147
150
$visitors = getVisitorsAndEvents(); // pseudo function, make your own logic here
148
151
149
152
foreach ($visitors as $collection) {
@@ -185,54 +188,6 @@ foreach ($visitors as $collection) {
0 commit comments