TinaCMS is a Git-backed headless CMS with visual editing capabilities. It stores content as Markdown/MDX files in your Git repository and provides a visual editor that runs on top of your frontend (typically Next.js). Analytics issues on TinaCMS sites trace to the Git-based publishing workflow, the visual editor injecting editing UI that triggers analytics, or the static generation pipeline not including analytics configuration.
TinaCMS-Specific Debugging Approach
TinaCMS is unique because content lives in your Git repo as files. There is no separate API server in production (unless using Tina Cloud). Debugging analytics means checking your frontend framework's build output and the visual editor's impact.
Check Build Output for Analytics
# For Next.js + TinaCMS, check the built HTML
# After build:
grep -r "gtag\|gtm\|analytics" .next/server/pages/ | head -5
# Check if analytics config is in the content files
grep -r "tracking\|analytics\|gtm" content/ --include="*.md" --include="*.mdx" --include="*.json"
Verify Visual Editor Is Not Inflating Data
// In browser console, detect TinaCMS visual editor
console.log('Tina editor:', document.querySelector('[data-tina-field]') ? 'Active' : 'Not detected');
console.log('Tina admin:', window.location.pathname.startsWith('/admin') ? 'Yes' : 'No');
console.log('Edit mode:', new URLSearchParams(window.location.search).has('edit') ? 'Yes' : 'No');
Most Common TinaCMS Analytics Issues
1. Visual Editor Mode Firing Production Analytics
Symptoms: Pageview spikes during content editing. Editor route /admin or ?edit=true URLs appear in GA.
Root cause: TinaCMS's visual editor loads your production site with an editing overlay. If analytics is not suppressed in edit mode, all editorial interactions generate tracking data.
Fix:
// Detect TinaCMS edit mode and suppress analytics
const isTinaEdit = window.location.pathname.startsWith('/admin') ||
new URLSearchParams(window.location.search).has('edit') ||
document.querySelector('[data-tina-field]') !== null;
if (isTinaEdit) {
window['ga-disable-G-XXXXXXX'] = true;
console.log('TinaCMS edit mode — analytics disabled');
}
2. Static Build Missing Analytics Configuration
Symptoms: Analytics works in next dev but not on the deployed static site.
Root cause: If analytics configuration is stored in a TinaCMS content file (e.g., content/global/settings.json), it is read at build time. If the file is missing, has a typo in the field name, or the GraphQL query does not fetch it, the build output lacks analytics.
Diagnosis:
# Check your TinaCMS content file
cat content/global/settings.json | python3 -m json.tool | grep -i "tracking\|analytics"
# Verify the TinaCMS GraphQL query fetches settings
grep -r "getGlobalDocument\|globalSettings\|settings" tina/ --include="*.ts" --include="*.tsx"
Fix: Add a fallback in your layout component:
// In your Next.js layout
import { useTina } from 'tinacms/dist/react';
export default function Layout({ children, globalData }) {
const { data } = useTina({ query: globalData.query, variables: globalData.variables, data: globalData.data });
const trackingId = data?.global?.trackingId || process.env.NEXT_PUBLIC_GA_ID;
return (
<>
{trackingId && (
<Script src={`https://www.googletagmanager.com/gtag/js?id=${trackingId}`} strategy="afterInteractive" />
)}
{children}
</>
);
}
3. Git-Based Publishing Delays
Symptoms: Content editor saves a change in TinaCMS, but the live site does not update for minutes (or until the next deploy).
Root cause: TinaCMS commits content changes to Git. If your deployment is triggered by Git pushes (Vercel, Netlify, etc.), there is a build + deploy delay between the Git commit and the live site update.
Fix: This is inherent to the Git-based workflow. For time-sensitive analytics changes:
- Use environment variables for tracking IDs instead of TinaCMS content fields
- Use ISR (Incremental Static Regeneration) to reduce rebuild times
- Configure webhook-triggered deployments for faster propagation
4. MDX Content Stripping Script Tags
Symptoms: Analytics code added to an MDX content file does not render.
Root cause: TinaCMS processes MDX files through its content pipeline. Raw <script> tags in MDX may be stripped or sanitized during rendering.
Fix: Do not put analytics code in MDX content files. Place it in your framework's layout component instead:
// In pages/_app.tsx or app/layout.tsx
// NOT in content/*.mdx files
import Script from 'next/script';
function MyApp({ Component, pageProps }) {
return (
<>
<Script src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX" strategy="afterInteractive" />
<Component {...pageProps} />
</>
);
}
5. Client-Side Navigation Not Tracked
Symptoms: First page load fires analytics, but clicking between pages shows no additional pageviews.
Root cause: Next.js (TinaCMS's primary framework) uses client-side routing. Page transitions do not trigger full page reloads.
Fix:
'use client';
import { usePathname } from 'next/navigation';
import { useEffect } from 'react';
export function TinaAnalytics() {
const pathname = usePathname();
useEffect(() => {
gtag('event', 'page_view', {
page_path: pathname,
page_title: document.title
});
}, [pathname]);
return null;
}
Environment Considerations
- Git-backed: All content is in your Git repo. No separate CMS server to manage in production (unless using Tina Cloud for the editor backend)
- Tina Cloud vs self-hosted: Tina Cloud provides the editing backend as a service. Self-hosted TinaCMS runs the editor locally. Analytics behavior is the same for visitors
- Next.js primary: TinaCMS is optimized for Next.js. Other frameworks (Astro, Hugo) have varying levels of TinaCMS support
- Build-time data: Content is resolved at build time for static pages. Analytics configuration changes require a rebuild to take effect
- Local development: The visual editor runs in local dev mode. Ensure analytics is disabled or uses a test property during local development
Performance Issues
- LCP Issues - Static build output performance and Next.js hydration timing
- CLS Issues - Layout shifts from visual editor overlay injection and dynamic content loading
Tracking Issues
- Events Not Firing - Debug visual editor mode, build-time content resolution, and client-side routing
Related Resources
- TinaCMS documentation
- Global Issues Hub for platform-agnostic solutions