Datocms Troubleshooting: Common Issues and Fixes | OpsBlu Docs

Datocms Troubleshooting: Common Issues and Fixes

Common issues and solutions for DatoCMS-powered websites including performance optimization and tracking problems.

Find solutions to common issues with DatoCMS-powered websites, from performance optimization to tracking implementation problems.

Common Issue Categories

Performance Issues

Performance problems can significantly impact user experience and SEO rankings.

Largest Contentful Paint (LCP)

  • Slow Imgix image loading
  • GraphQL query performance
  • Framework-specific rendering delays
  • Target: Under 2.5 seconds

Cumulative Layout Shift (CLS)

  • Images without dimensions from DatoCMS
  • Dynamic content shifting
  • Font loading issues
  • Target: Under 0.1

First Input Delay (FID) / INP

Tracking Issues

Problems with analytics and conversion tracking implementation.

Events Not Firing

Data Layer Problems

  • Incorrect DatoCMS data structure
  • Missing content fields
  • Type mismatches
  • Preview mode contamination

Cross-Domain Tracking

  • Multi-locale tracking issues
  • Subdomain configuration
  • Referrer tracking problems

Content Issues

DatoCMS-specific content delivery problems.

GraphQL Query Errors

  • Query syntax errors
  • Missing fields
  • Rate limiting
  • API token issues

Image Loading Problems

  • Imgix transformation errors
  • Responsive images not working
  • Blur placeholders failing
  • WebP format issues

Preview Mode Issues

  • Preview not showing latest content
  • Preview contaminating analytics
  • Authentication failures
  • Real-time updates not working

Build and Deployment

Framework build and deployment issues.

Next.js Build Failures

  • Static generation errors
  • Image optimization failures
  • GraphQL query errors at build time
  • Environment variable issues

Gatsby Build Problems

  • gatsby-source-datocms errors
  • Out of memory errors
  • GraphQL schema conflicts
  • Image processing failures

ISR Issues

  • Revalidation not working
  • Stale content served
  • On-demand revalidation failures

Quick Diagnostic Tools

Check DatoCMS API Status

# Test API connectivity
curl -X POST https://graphql.datocms.com/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "{ _allContentTypesMeta { count } }"}'

Verify Image Optimization

Test Imgix image URLs:

https://www.datocms-assets.com/YOUR_PROJECT/image.jpg?w=800&auto=format

Debug GraphQL Queries

Use DatoCMS GraphQL Explorer:

  1. Go to DatoCMS Dashboard
  2. Settings → API Explorer
  3. Test your queries interactively

Check Performance Scores

Tools to diagnose performance:

Verify Tracking

Debug tracking implementation:

  • GA4: Use DebugView in Google Analytics
  • GTM: Enable Preview mode
  • Meta Pixel: Install Meta Pixel Helper extension
  • Console: Check window.dataLayer or window.fbq

Framework-Specific Issues

Next.js

Common Next.js + DatoCMS issues:

Build Errors

// Issue: GraphQL query fails at build time
// Solution: Add error handling
export async function getStaticProps() {
  try {
    const data = await fetchDatoCMSContent()
    return { props: { data } }
  } catch (error) {
    console.error('DatoCMS fetch error:', error)
    return { notFound: true }
  }
}

Image Optimization

// Issue: Images from DatoCMS not optimizing
// Solution: Configure image loader
// next.config.js
module.exports = {
  images: {
    loader: 'custom',
    loaderFile: './lib/datocms-image-loader.ts',
  },
}

Gatsby

Source Plugin Errors

# Issue: gatsby-source-datocms failing
# Solution: Clear cache and rebuild
gatsby clean && gatsby build

Memory Issues

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-source-datocms',
      options: {
        apiToken: process.env.DATOCMS_API_TOKEN,
        previewMode: false,
        disableLiveReload: true, // Reduce memory usage
      },
    },
  ],
}

Environment-Specific Debugging

Development

Enable verbose logging:

// lib/datocms.ts
export async function fetchDatoCMS(query: string) {
  if (process.env.NODE_ENV === 'development') {
    console.log('DatoCMS Query:', query)
  }

  const response = await fetch('https://graphql.datocms.com/', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.DATOCMS_API_TOKEN}`,
    },
    body: JSON.stringify({ query }),
  })

  const data = await response.json()

  if (process.env.NODE_ENV === 'development') {
    console.log('DatoCMS Response:', data)
  }

  return data
}

Production

Monitor errors:

// Implement error tracking
export async function fetchDatoCMSWithTracking(query: string) {
  try {
    return await fetchDatoCMS(query)
  } catch (error) {
    // Send to error tracking service
    if (typeof window !== 'undefined' && window.gtag) {
      window.gtag('event', 'exception', {
        description: 'DatoCMS API Error',
        fatal: false,
      })
    }
    throw error
  }
}

Getting Help

DatoCMS Support

Framework Support

Analytics Support

Troubleshooting Guides

By Topic

By Issue Type

Performance

  • Slow GraphQL queries → LCP Guide
  • Layout shifts → CLS Guide
  • Large bundles → Optimize dependencies and code splitting

Tracking

  • Missing events → Events Guide
  • Wrong data → Check data layer configuration
  • Privacy issues → Implement consent management

Content

  • Query errors → Check API Explorer
  • Missing images → Verify asset uploads
  • Preview issues → Check authentication

Prevention Best Practices

  1. Testing: Test in development before production deploy
  2. Monitoring: Set up performance monitoring (Core Web Vitals)
  3. Error Tracking: Implement error logging (Sentry, LogRocket)
  4. Validation: Validate GraphQL queries before deployment
  5. Fallbacks: Implement graceful error handling