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
- In Google Tag Manager, go to Templates, search for
GTAG GET APIin the template gallery, and click Add to workspace. - Go to Tags and create a new tag using the GTAG GET API template.
- Set your GA4 Measurement ID in the appropriate field.
- Check the box next to Session ID under Default Fields to Get.
- 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.
- 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 beforegtag()had time to load. - Create a Marketing Data field:
- Type: Short Text
- Partner (API) Name:
ga_session_id - Friendly Name: Google Analytics Session ID
- Attribution Model: Last Touch
- 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.
- Test that the session ID attribution is being captured as expected before publishing your draft.