ga4-data-layer-guide

ga4-data-layer-guide is a skill for Claude Code from Ad-Superpowers/ad-superpowers-plugin. It costs 101 tokens per session (4,315 once invoked), scanned A, original, MIT.

A practical guide to building a website data layer for Google Tag Manager and Google Analytics 4 (GA4). A data layer is a shared JavaScript array where a site places structured information for tracking.

In plain words
What is it for?
Use it to plan and implement dataLayer structures, send website and e-commerce data to Google Tag Manager, and inspect data-layer contents during tracking work.
Why use it?
It helps keep website data separate from tracking rules, so tracking changes need less code editing and data stays in a consistent format. It also provides a defined way to inspect tracking data.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the ad-superpowers plugin — 120 skills, 35 commands, 5 agents, 1 MCP server shipped together

Good fit Use it to plan and implement dataLayer structures, send website and e-commerce data to Google Tag Manager, and inspect data-layer contents during tracking work.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ad-superpowers/ad-superpowers-plugin/ga4-data-layer-guide
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Ad-Superpowers/ad-superpowers-plugin --skill ga4-data-layer-guide
Clone the repo
git clone --depth 1 https://github.com/Ad-Superpowers/ad-superpowers-plugin

Made for: Claude Code.

Or install ad-superpowers, the plugin that ships this one along with the rest of its 120 skills, 35 commands, 5 agents, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ga4-data-layer-guide

README.md
[![agentmods](https://agentmods.dev/badge/skills/ad-superpowers/ad-superpowers-plugin/ga4-data-layer-guide/github.svg)](https://agentmods.dev/skills/ad-superpowers/ad-superpowers-plugin/ga4-data-layer-guide)
Your own site
<a href="https://agentmods.dev/skills/ad-superpowers/ad-superpowers-plugin/ga4-data-layer-guide"><img src="https://agentmods.dev/badge/skills/ad-superpowers/ad-superpowers-plugin/ga4-data-layer-guide/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ga4-data-layer-guide

Your own site · 80×15
<a href="https://agentmods.dev/skills/ad-superpowers/ad-superpowers-plugin/ga4-data-layer-guide"><img src="https://agentmods.dev/badge/skills/ad-superpowers/ad-superpowers-plugin/ga4-data-layer-guide.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 101 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,315 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00101 $0.04315
Opus 5.5 $0.00040 $0.01726
Sonnet 5.5 $0.00020 $0.00863
Haiku 4.5 $0.00010 $0.00432

Measured 1mo ago against content hash 315b052a18d9, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ga4-data-layer-guide scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugin/skills/ga4-data-layer-guide/SKILL.md · 707 lines

How it starts

The opening of the file, as written. The whole thing — 707 lines — stays where its author put it; the contents beside it link to each section on GitHub.

GA4 Data Layer Guide

Complete guide for implementing a robust Data Layer for Google Analytics 4 via Google Tag Manager.

Data Layer Basics

WHAT IS THE DATA LAYER?
=======================

┌────────────────────────────────────────────────────────────────┐
│  dataLayer = JavaScript array that shares data with GTM        │
│                                                                │
│  FLOW:                                                         │
│  ┌──────────┐    ┌──────────┐    ┌──────────┐    ┌──────────┐ │
│  │ Website  │ -> │ dataLayer│ -> │   GTM    │ -> │   GA4    │ │
│  │  Code    │    │  Array   │    │  Tags    │    │ Property │ │
│  └──────────┘    └──────────┘    └──────────┘    └──────────┘ │
│                                                                │
│  ADVANTAGES:                                                   │
│  ├── Separation of data and tracking logic                     │
│  ├── Flexibility: modify tracking without code changes         │
│  ├── Reliability: data available when needed                   │
│  ├── Structured data: consistent formats                       │
│  └── Debug-friendly: easy to inspect                           │
└────────────────────────────────────────────────────────────────┘

BASIC SYNTAX:
─────────────
// Initialize dataLayer (before GTM snippet)
window.dataLayer = window.dataLayer || [];

// Push data to dataLayer
dataLayer.push({
  'event': 'event_name',
  'key': 'value'
});

Data Layer Initialization

CORRECT DATA LAYER SETUP
=========================

STEP 1: Initialize before GTM
──────────────────────────────

PLACE IN <head>, BEFORE GTM snippet:

```html
<script>
  window.dataLayer = window.dataLayer || [];

  // Optional: initial page data
  dataLayer.push({
    'pageType': 'product',
    'pageCategory': 'electronics',
    'userLoggedIn': true,
    'userId': 'user_12345',
    'userType': 'returning'
  });
</script>

<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){...})(window,document,'script','dataLayer','GTM-XXXXX');</script>
<!-- End Google Tag Manager -->

STEP 2: GTM Container Code ─────────────────────────── GTM snippet comes AFTER the Data Layer initialization. This ensures data is available at page load.

ORDER IS CRITICAL: ──────────────────

  1. dataLayer = window.dataLayer || [];
  2. dataLayer.push({initial page data});
  3. GTM tag
  4. Rest of the page
  5. dataLayer.push() for events (forms, clicks, etc.)

Read the full file on GitHub · 707 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 707 lines · 101 tokens per session scan A 315b052a18d9

Subscribe to this mod's changes

ga4-data-layer-guide is a skill published in the GitHub repository Ad-Superpowers/ad-superpowers-plugin (5 stars, last pushed 29d ago), licensed MIT. It adds 101 tokens to every session and 4,315 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-11.

Related

Other skills, from other repositories

sealeap-amazon-ca-apparel-ads

An Amazon Canada advertising planning guide for apparel products such as coats and underwear. It combines product life-cycle stages, seasonal timing, English and French search coverage, account evidence, profitability, and inventory considerations.

xjli360/sealeap-amazon-ad-skills · 158 tokens

sealeap-amazon-listing-optimizer

Audit, diagnose, rewrite, creatively brief, test, and safely prepare updates for Amazon product detail pages using live marketplace and product-type requirements, verified product facts, Brand Analytics, Search Query Performance, Ads search terms, customer feedback, competitor observations, and optional third-party…

xjli360/sealeap-amazon-ad-skills · 147 tokens

ai-model-expert-1688-ecommerce-video-generation-editing

An AI tool workflow for creating and editing 1688 e-commerce videos from text, images, videos, or audio. 1688 is a Chinese online wholesale marketplace.

wubin1836/ai-hive-agent-skills · 330 tokens

302-ai-alternative-ai-hive

A migration guide for teams moving between AI model API platforms, especially for image and video generation. It helps review an existing OpenAI-compatible integration and plan testing, routing, and fallback options.

wubin1836/ai-hive-agent-skills · 229 tokens

ai-hive-animation-167-e6ff654

An AI-HIVE workflow for creating original 8-bit pixel-art animation or game-oriented content. It covers characters, settings, storyboards, key frames, animation clips, and checks for visual consistency and originality.

wubin1836/ai-hive-agent-skills · 143 tokens

ai-hive-agentic-ocr-targeted-evidence

A document-search workflow that first finds likely pages and then uses OCR, or software that reads text from images, on only the relevant scans, tables, or small text.

wubin1836/ai-hive-agent-skills · 169 tokens