Google Analytics session number now accessible via gtag.js get API update

August 26, 2025 at 3:16:22 AM

TL;DR The gtag.js get() API now supports retrieving the Google Analytics session number from the session cookie, in addition to the session ID. The get command fetches values set with gtag.js, using gtag('get', '<target>', '<field_name>', callback). Supported field names include client_id, session_id, session_number for GA4, and gclid for Google Ads and Floodlight.

Google Analytics session number now accessible via gtag.js get API update

The gtag.js get() API has been enhanced to support parsing the Google Analytics session number from the session cookie, expanding beyond the previous capability of only retrieving the session ID. This update aligns with Google Tag Manager's custom templates functionality.

gtag.js get() API Overview

The get command in gtag.js allows retrieval of various values, including those set with the set command, using the syntax:

gtag('get', '<target>', '<field_name>', callback)
  • <target>: A string specifying the target to fetch values from (e.g., G-XXXXXXXXXX).
  • <field_name>: The name of the field to retrieve.
  • callback: A function invoked with the requested field value or undefined if the field is unset.

Supported Field Names

Field names can be custom fields set via gtag('set') or predefined fields:

Field Name Supported Targets
client_id Google Analytics 4
session_id Google Analytics 4
session_number Google Analytics 4
gclid Google Ads, Floodlight

This enhancement allows developers to access the session number directly, improving session tracking capabilities within Google Analytics 4 via gtag.js.

Have more questions on this topic? Ask our AI assistant for in-depth insights.

Read more from sources πŸ‘‡

Simo Ahava
Simo Ahava

Top Creator

Top Analytics Creator

Simo Ahava is a Top Analytics Creator. Part of Swipe Insight Select, a curated list of top creators.

Top Analytics Creator
- The gtag.js get() API now supports retrieving the Google Analytics session number from the session cookie, in addition t... Visit Source Open external source URL

The Only Digital Marketing Feed You'll Ever Need.

Stay informed your way. Tailored updates when and how you want them. 100% Free.

10,000+ Users

500+ Sources

1000+ Tools

Or

Related Posts

GA4 introduces API access for identity settings in reports

GA4 introduces API access for identity settings in reports

Brais Calvo
Brais Calvo

Top Creator

Top Analytics Creator

Brais Calvo is a Top Analytics Creator. Part of Swipe Insight Select, a curated list of top creators.

Top Analytics Creator
Update to server-side Google Tag Manager changes how Google libraries load

Update to server-side Google Tag Manager changes how Google libraries load

Simo Ahava
Simo Ahava

Top Creator

Top Analytics Creator

Simo Ahava is a Top Analytics Creator. Part of Swipe Insight Select, a curated list of top creators.

Top Analytics Creator
Google Analytics Now Supports Importing Cost Data from Reddit Ads Seamlessly

Google Analytics Now Supports Importing Cost Data from Reddit Ads Seamlessly

Google
Google

Official Source

Official Source

Google is a Official Source. The source has been verified by Swipe Insight team.

Official Source
Top-Notch Google Ads Audit Tool

Top-Notch Google Ads Audit Tool

Featured
Google Analytics launches local MCP supporting GA4 API with secure data access Trending ️‍πŸ”₯

Google Analytics launches local MCP supporting GA4 API with secure data access

Google
Google

Official Source

Official Source

Google is a Official Source. The source has been verified by Swipe Insight team.

Official Source
New Web Analytics Community Launches to Support Marketers and Data Professionals

New Web Analytics Community Launches to Support Marketers and Data Professionals

GA4 adds item-level custom dimension import for enhanced ecommerce data

GA4 adds item-level custom dimension import for enhanced ecommerce data

Brais Calvo
Brais Calvo

Top Creator

Top Analytics Creator

Brais Calvo is a Top Analytics Creator. Part of Swipe Insight Select, a curated list of top creators.

Top Analytics Creator
GA4 adds new lead acquisition and disqualification reports with fresh lead metrics

GA4 adds new lead acquisition and disqualification reports with fresh lead metrics

Brais Calvo
Brais Calvo

Top Creator

Top Analytics Creator

Brais Calvo is a Top Analytics Creator. Part of Swipe Insight Select, a curated list of top creators.

Top Analytics Creator

Related Tools

Markifact logo

Markifact

Verified Tool

Verified Tool

Markifact is a Verified Tool. Want to get this badge? Contact us.

Verified Tool

Marketing Workflows Powered by AI

Featured
Marketing Auditor logo

Marketing Auditor

Verified Tool

Verified Tool

Marketing Auditor is a Verified Tool. Want to get this badge? Contact us.

Verified Tool

Automated audits for Google Ads and Analytics.

Get Featured Here

Showcase your tool in this list.

Contact Us
Branch logo

Branch

Seamless mobile linking and attribution solutions

GA4 Auditor logo

GA4 Auditor

Verified Tool

Verified Tool

GA4 Auditor is a Verified Tool. Want to get this badge? Contact us.

Verified Tool

Automated GA4 audits with actionable insights

Data Analysis
GA4 SQL logo

GA4 SQL

Verified Tool

Verified Tool

GA4 SQL is a Verified Tool. Want to get this badge? Contact us.

Verified Tool

Generate GA4 BigQuery queries easily

Data Analysis
Matomo logo

Matomo

Web analytics with full data ownership

Analytics
PostHog logo

PostHog

All-in-one platform for product analytics and testing

Analytics
easyTag.io logo

easyTag.io

Effortless GA4 server-side tracking

Rockerbox logo

Rockerbox

Simplified marketing data for strategic decisions

Plausible Analytics logo

Plausible Analytics

Lightweight, privacy-friendly web analytics

Analytics

Get Featured Here

Showcase your tool in this list.

Contact Us