> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invoca.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Expose the Google Analytics Session ID in the JavaScript Data Layer from Google Tag Manager

> Use the GTAG GET API template in Google Tag Manager to surface the GA4 session ID in your data layer, then capture it with the Invoca Tag.

## Applies to

* Customers using Invoca's Google Analytics 4 integration
* Customers integrated with multiple Google Analytics properties
* Customers using Google Tag Manager to manage their GA4 tags

## Objective

Capture attribution for the Google Analytics session ID.

## Steps

1. In Google Tag Manager, go to **Templates**, search for `GTAG GET API` in the template gallery, and click **Add to workspace**.
2. Go to **Tags** and create a new tag using the GTAG GET API template.
3. Set your **GA4 Measurement ID** in the appropriate field.
4. Check the box next to **Session ID** under Default Fields to Get.
5. Add this tag to a tag sequence so it fires **after** your GA4 Configuration tag (or Event tag, if you're not using a Configuration tag): open your Google Analytics 4: Configuration tag, go to Advanced Settings > Tag Sequencing, check "Fire a tag after … fires," and select the tag you just created.
6. In Preview mode, confirm you see a new Data Layer event named `gtagApiGet`. If you don't, either there's no GA4 configuration on the page, or the API tag fired before `gtag()` had time to load.
7. Create a Marketing Data field:
   * **Type:** Short Text
   * **Partner (API) Name:** `ga_session_id`
   * **Friendly Name:** Google Analytics Session ID
   * **Attribution Model:** Last Touch
8. Update your Invoca Tag to capture the session ID:
   * Click the gear icon, then **Invoca Tags**, and find the Tag for the site with the GA4 property you're integrating.
   * Open the Revision History tab and create a new draft (or continue an existing one).
   * Find the Google Analytics Session ID parameter in the Marketing Data section.
   * Set **Data Source Type** to **JavaScript Data Layer**, and paste the session ID variable name as the **Data Source Name**.
9. Test that the session ID attribution is being captured as expected before publishing your draft.

## Where to go next

* [How to Capture the Session ID for Multiple Data Streams](/s/article/capture-session-id-multiple-data-streams)
* [Creating Marketing Data Fields](/s/article/creating-marketing-data-fields)
* [Filter Call Data for Multiple GA4 Properties](/s/article/filter-call-data-multiple-ga4-properties)
