gtm-optimization
OfficialBoost GTM/GA performance with dynamic imports.
AuthorSilverAssist
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill helps Next.js apps run GTM/GA analytics without blocking the initial render by replacing inline script patterns with a dynamic import approach via @next/third-parties. It reduces render-blocking JavaScript and improves Core Web Vitals while preserving analytics fidelity.
Core Features & Use Cases
- Dynamic import pattern for GTM/GA using @next/third-parties to load analytics client-side after hydration.
- Reduces render-blocking JavaScript and improves FCP, LCP, and TBT in production environments.
- Use cases include migrating from inline <Script> tags to a reusable analytics wrapper in Next.js apps and applying the pattern to GA4 and GTM deployments.
Quick Start
- Install the required dependency: npm install @next/third-parties
- Create a small client wrapper component that dynamically loads GTM/GA after hydration
- Replace inline analytics Script usage in your root layout with the wrapper and set environment variables NEXT_PUBLIC_GTM_ID or NEXT_PUBLIC_GA_ID
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: gtm-optimization Download link: https://github.com/SilverAssist/performance-toolkit/archive/main.zip#gtm-optimization Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.