Skip to content

Commit bd8dba1

Browse files
committed
fixes
1 parent e2344d7 commit bd8dba1

File tree

1 file changed

+2
-0
lines changed
  • src/connections/destinations/catalog/actions-google-analytics-4

1 file changed

+2
-0
lines changed

src/connections/destinations/catalog/actions-google-analytics-4/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The Google Analytics 4 reports only display active users who engage with your si
8282
If you choose to integrate with Google Analytics 4 client-side (using Gtag outside of Segment) _and_ also use Segment's Google Analytics 4 destination to send events through the API, you can track sessions server-side. When using Gtag, [Google generates a `session_id` and `session_number` when a session begins](https://support.google.com/analytics/answer/9191807?hl=en){:target='_blank'}. The `session_id` and `session_number` generated on the client can be passed as Event Parameters to stitch events sent through the API with the same session that was collected client-side.
8383

8484
You can double-check your session_id and session_number with the [Google Site Tag function](https://developers.google.com/tag-platform/gtagjs/reference){:target='_blank'} or by running this script in your JavaScript console and replacing `G-xxxxxxxxxx` with your GA4 measurement ID:
85+
8586
```java
8687
const sessionIdPromise = new Promise(resolve => {
8788
gtag('get', 'G-xxxxxxxxxx', 'session_id', resolve)
@@ -94,6 +95,7 @@ Promise.all([sessionIdPromise, sessionNumPromise]).then(function(session_data) {
9495
console.log("session ID: "+session_data[0]);
9596
console.log("session Number: "+session_data[1]);
9697
});
98+
```
9799

98100
> info "Session tracking limitations"
99101
> Session tracking server-side only works if you're also sending data to Google Analytics 4 client-side. This is because the `session_id` must match a value that was previously collected on the client. For events to stitch properly, they must arrive within a 48 hour window of when the client-side events arrived.

0 commit comments

Comments
 (0)