Skip to main content
Can’t find your issue? Chat with us using the support widget or email [email protected]

Quick Diagnostics

If you’re seeing errors, start here:
1

Check Browser Console

Open your browser’s developer tools (F12 or Cmd+Option+I) and look for errors in the Console tab.
2

Verify Installation

Type window.grain in the console. If it returns undefined, the SDK isn’t loaded.
3

Check Network Tab

Look for failed requests to api.grainql.com in the Network tab (F12 → Network).

Authentication Errors (401)

Session Expired / Token Not Found

Error Message:
  • “Your session has expired. Please refresh the page or sign in again.”
  • “Authentication required”
Common Causes:
  • Your login session expired (tokens expire after inactivity)
  • Cookies were cleared or blocked
  • Using the app in private/incognito mode
Solutions:
  1. Click the Reload Page button in the error message
  2. If that doesn’t work, sign out and sign back in
If you keep getting logged out:
  • Check if your browser is blocking third-party cookies
  • Disable ad blockers or tracking protection for grainql.com
  • Try a different browser to isolate the issue
  • Clear browser cache and cookies for grainql.com
If you’re using the SDK and seeing auth errors:
// Make sure you're initializing with correct credentials
grain.init({
  tenantId: 'your-tenant-id', // Check this is correct
  // ...other options
});
Verify your tenant ID in the dashboard settings.
Related Documentation:

Network Errors

Connection Failed / Cannot Reach Server

Error Message:
  • “Network connection issue. Please check your internet connection and try again.”
  • “Failed to fetch”
  • “Network error: Unable to connect to server”
Common Causes:
  • No internet connection
  • Firewall or proxy blocking requests
  • VPN interfering with connections
  • DNS resolution issues
Solutions:
  1. Check your internet connection
  2. Try accessing https://api.grainql.com/health directly
  3. If the API is unreachable, check if your network blocks analytics services
If you’re on a corporate network:
  • Whitelist api.grainql.com in your firewall
  • Whitelist *.grainql.com to allow all subdomains
  • Check if your proxy requires authentication
  • Contact your IT department to allow analytics traffic
Ad blockers and privacy extensions may block Grain:
  • Temporarily disable browser extensions
  • Add grainql.com to your extension’s whitelist
  • Try loading the site in incognito mode (without extensions)

Server Errors (500, 502, 503)

Internal Server Error / Service Unavailable

Error Message:
  • “Our servers are experiencing issues. Please try again in a few moments.”
  • “API error 500”
  • “Service temporarily unavailable”
What This Means: There’s an issue on our end. These are usually temporary. Solutions:
1

Wait and Retry

Wait 1-2 minutes and refresh the page. Most issues resolve automatically.
2

Check Status

Check our status page for known incidents (if available).
3

Report Persistent Issues

If the error persists for more than 5 minutes, contact support with:
  • Error message and code
  • Time the error occurred
  • What action you were trying to perform

Rate Limiting (429)

Too Many Requests

Error Message:
  • “Rate limit exceeded. Please try again later.”
  • “Too many requests”
What This Means: You’ve exceeded the API rate limits for your plan. Solutions:
// Reduce event volume by being selective
// DON'T track every mouse move
window.addEventListener('mousemove', () => {
  grain.track('mouse_move'); // ❌ TOO MANY EVENTS
});

// DO track meaningful interactions
button.addEventListener('click', () => {
  grain.track('cta_clicked'); // ✅ GOOD
});
// Implement client-side caching
const cache = new Map();

async function fetchWithCache(endpoint) {
  if (cache.has(endpoint)) {
    return cache.get(endpoint);
  }
  
  const data = await fetch(endpoint);
  cache.set(endpoint, data);
  return data;
}

// Batch multiple queries instead of making them separately
// Use longer intervals for auto-refresh features
If you consistently hit limits, upgrade your plan for higher quotas.
Related Documentation:

SDK Not Loading

window.grain is Undefined

Symptoms:
  • Console error: grain is not defined
  • Events not being tracked
  • No network requests to api.grainql.com
Solutions by Installation Method:
// ❌ Common mistake - forgetting to import
grain.track('event');

// ✅ Correct - import first
import grain from '@grainql/analytics-web';

grain.init({ tenantId: 'your-tenant-id' });
grain.track('event');
Check that:
  • Package is installed: npm list @grainql/analytics-web
  • Import statement is present
  • Init is called before tracking

Events Not Appearing in Dashboard

Events Sent But Not Visible

Possible Causes:
Events can take 1-2 minutes to appear in the dashboard.Solution: Wait 2-3 minutes and refresh the dashboard.
You might be sending events to the wrong tenant.
// Check your tenant ID matches the dashboard
grain.init({
  tenantId: 'your-tenant-id' // Verify this!
});
Find your tenant ID: Dashboard → Settings → Tenant ID
Check if you have filters applied in the dashboard:
  • Date range too narrow
  • Event name filters active
  • User filters excluding your events
Check browser console and Network tab for:
  • Failed POST requests to /v1/events
  • CORS errors
  • 4xx or 5xx status codes
Debug Checklist:
// Add this temporarily to verify events are being sent
grain.init({
  tenantId: 'your-tenant-id',
  debug: true // Enable debug logging
});

// Check console for:
// ✅ "Grain Analytics initialized"
// ✅ "Tracking event: event_name"
// ✅ "Event sent successfully"

Dashboard Errors

Data Not Loading / Blank Charts

Error Message:
  • “Error fetching dashboard data”
  • “Failed to load analytics”
Solutions:
1

Check Date Range

Make sure you have data for the selected date range. Try “Last 30 days”.
2

Verify Events Exist

Go to Database view → Events tab to see if any events were received.
3

Check Permissions

If you’re a team member, verify you have viewer/editor access to the tenant.
4

Clear Browser Cache

Dashboard uses caching. Clear cache or try incognito mode.

Mission Control Not Loading

Specific to Mission Control (conversion tracking):
Mission Control requires at least one goal to be set up.Solution:
  1. Go to Mission Control
  2. Click “Configure Goals”
  3. Set up your first conversion goal
Goals need at least 10 events to show statistics.Solution: Wait for more data to accumulate or send test events.

CORS Errors

Cross-Origin Request Blocked

Error Message:
  • “Access to fetch at ‘https://api.grainql.com/…’ blocked by CORS policy”
  • “No ‘Access-Control-Allow-Origin’ header”
What This Means: Your domain isn’t whitelisted in tenant settings. Solution:
1

Add Your Domain

Go to Dashboard → Settings → Allowed Origins
2

Add Origin

Add your domain (e.g., https://example.com)For development: http://localhost:3000
3

Wildcards for Subdomains

Use https://*.example.com to allow all subdomains
Common Patterns:
// Production
https://example.com

// All subdomains
https://*.example.com

// Development (multiple ports)
http://localhost:3000
http://localhost:3001
http://localhost:5173

// Mobile preview
http://192.168.1.100:3000

TypeScript Errors

Type Issues with SDK

Common Issues:
// Error: Cannot find module '@grainql/analytics-web'

// Solution 1: Install types (already included)
npm install @grainql/analytics-web

// Solution 2: Check tsconfig.json
{
  "compilerOptions": {
    "moduleResolution": "node",
    "esModuleInterop": true
  }
}
// Error: Property 'grain' does not exist on type 'Window'

// Solution: Extend Window interface
declare global {
  interface Window {
    grain: typeof import('@grainql/analytics-web').default;
  }
}
// For type-safe event properties
import type { EventProperties } from '@grainql/analytics-web';

interface CustomEventProps extends EventProperties {
  category: string;
  value: number;
}

grain.track<CustomEventProps>('purchase', {
  category: 'electronics',
  value: 99.99
});
Related Documentation:

Performance Issues

Slow Page Load / High Bundle Size

If using npm package:
// ❌ Imports entire SDK synchronously
import grain from '@grainql/analytics-web';

// ✅ Lazy load for better performance
const grain = await import('@grainql/analytics-web');
If using CDN:
<!-- ✅ Use async to avoid blocking page load -->
<script async src="https://cdn.grainql.com/grain.js"></script>
Reduce Event Volume:
// ❌ Too many events
window.addEventListener('scroll', () => {
  grain.track('scroll'); // Fires constantly!
});

// ✅ Throttle or debounce
import { throttle } from 'lodash';

window.addEventListener('scroll', throttle(() => {
  grain.track('scroll');
}, 1000)); // Once per second max

Integration-Specific Issues

“Cannot use import statement outside a module”
// ❌ Don't do this
import grain from '@grainql/analytics-web';

// ✅ Use next/script for client-side
import Script from 'next/script';

<Script src="https://cdn.grainql.com/grain.js" />
See Next.js Quick Start for full setup.
Events firing multiple times in developmentThis is normal in React 18 StrictMode (development only).
// Events may fire twice in dev, but only once in production
useEffect(() => {
  grain.track('page_view');
}, []);
See React Quick Start for more.
Theme conflictsSome themes interfere with the SDK. See Shopify Integration.
Plugin conflictsCaching or optimization plugins may break tracking. See WordPress Integration.

Validation Errors (400)

Invalid Input / Malformed Request

Common Validation Errors:
// ❌ Invalid
grain.init({ tenantId: 'abc' }); // Too short
grain.init({ tenantId: 'my tenant' }); // Spaces not allowed

// ✅ Valid
grain.init({ tenantId: 'my-tenant-123' }); // 4-32 chars, alphanumeric + hyphens
// ❌ Invalid
grain.track('My Event!'); // Special chars not allowed
grain.track(''); // Empty string

// ✅ Valid
grain.track('my_event'); // snake_case recommended
grain.track('button-clicked'); // kebab-case also ok
// ❌ Invalid
grain.track('event', {
  circular: window, // Circular references not allowed
  func: () => {}, // Functions not allowed
});

// ✅ Valid
grain.track('event', {
  category: 'value',
  count: 42,
  enabled: true,
  tags: ['a', 'b'],
  metadata: { key: 'value' }
});
Related Documentation:

Still Having Issues?

If none of the above solutions work:

Live Chat

Click the chat widget in the bottom-right corner of grainql.com

Email Support

Email us at [email protected] with:
  • Error message and code
  • Browser console logs
  • Network tab screenshot
  • Steps to reproduce

Community Discord

Join our Discord for community support (coming soon)

GitHub Issues

Report SDK bugs on GitHub

Additional Resources