Update GA4 Docs Session ID and Session Number #2925
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
With the latest changes to the Google Measurement API, session data can now be sent to GA4 once the session_id and session_number are sent in the payload. Finding this data can be difficult for customers given that retrieving these values is not explicitly linked to the GA4 docs anywhere. This addition to our docs includes a working code example of how to retrieve these values from a site using gtag.
To test this code, I used the following GA4 property:



Installed the property on a locally hosted webpage:
Running the code in the console resulted in this output:
Matching the session ID and Number for the session_start event in the GA4 real-time report:


Merge timing