Google Tag Manager launches readAnalyticsStorage API to read GA client and session cookies

August 04, 2025 at 5:02:34 AM

TL;DR The readAnalyticsStorage sandbox API lets developers safely read Google Analytics client and session IDs in custom templates, replacing unreliable reverse-engineering methods. This prevents issues from cookie format changes. It is part of Google Tag Manager's custom template APIs, which use sandboxed JavaScript with require() statements. Another API, addConsentListener, registers functions to track consent state changes.

Google Tag Manager launches readAnalyticsStorage API to read GA client and session cookies

The new readAnalyticsStorage sandbox API enables developers to read Google Analytics client and session IDs directly within custom templates using client-side JavaScript. This replaces the unreliable method of reverse-engineering Google-set cookie formats, which often broke when Google Analytics updated its cookies. The API ensures a stable, future-proof way for Google Tag Manager users to access necessary cookie data without disruption.

Custom Template APIs Overview

Google Tag Manager supports several Core APIs for building custom templates in sandboxed JavaScript. These APIs are accessed via require() statements, for example:

const myAPI = require('myAPI');

Only the listed APIs are compatible with sandboxed JavaScript.

Example: addConsentListener API

  • Registers a listener function triggered when a specified consent type's state changes.
  • The listener activates when consent changes from denied to granted or vice versa.
  • Consent types with no state are treated as granted, so listeners won't fire when an unset consent type becomes granted.
  • Listener functions must manage their own execution frequency.

The readAnalyticsStorage API and other custom template APIs provide a safer, more reliable way to interact with Google Analytics data and consent states within Google Tag Manager.

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

Read more from sources πŸ‘‡

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

Top-Notch Google Ads Audit Tool

Top-Notch Google Ads Audit Tool

Featured
New Web Analytics Community Launches to Support Marketers and Data Professionals

New Web Analytics Community Launches to Support Marketers and Data Professionals

Google Tag Manager adds control to manage monitored domains in Container Diagnostics tool

Google Tag Manager adds control to manage monitored domains in Container Diagnostics tool

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
Google Unveils New AI Tools for Measurement and First-Party Data Strategies

Google Unveils New AI Tools for Measurement and First-Party Data Strategies

Google
Google

Official Source

Official Source

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

Official Source
First-party Mode with Cloudflare rebranded as Google Tag Gateway

First-party Mode with Cloudflare rebranded as Google Tag Gateway

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 Tag Manager Adds New Diagnostic Alerts and Dismissal Options for Users

Google Tag Manager Adds New Diagnostic Alerts and Dismissal Options for Users

Google
Google

Official Source

Official Source

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

Official Source
 Google Tag Manager Containers to Automatically Load Google Tag Starting April 2025 Trending ️‍πŸ”₯

Google Tag Manager Containers to Automatically Load Google Tag Starting April 2025

Google
Google

Official Source

Official Source

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

Official Source
 Google Tag Now Uses Service Workers to Enhance GTM Server-Side Data Transmission

Google Tag Now Uses Service Workers to Enhance GTM Server-Side Data Transmission

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