Skip to content

Debugging & Testing

This guide provides debugging tools and troubleshooting strategies for testing your analytics implementation. Use these techniques to verify events are being tracked correctly across all providers and identify issues.

Debug mode provides console logging of analytics events and provider interactions.

Enable debug mode in your analytics configuration:

analytics: {
debug: true // Enable in config
}

When debug mode is enabled, you’ll see detailed console output for every event tracked, including which providers received the event and any transformations applied.

Temporarily disable all tracking while testing your site without affecting session data.

Add the ?ignore=true query parameter to your URL:

https://yoursite.com?ignore=true

This disables ALL tracking for the entire session. All analytics events will be silently ignored.

When you’re finished testing, clear the ignore flag:

window.NextAnalyticsClearIgnore();

After calling this function, tracking will resume normally for new events.

Check that events are properly pushed to the data layer and available for your analytics platforms to consume.

View the raw event data in each data layer:

// NextAnalytics data layer
console.log(window.NextDataLayer);
// Google Tag Manager
console.log(window.dataLayer);
// Elevar (if enabled)
console.log(window.ElevarDataLayer);

When you track an event with debug mode enabled:

// Check data layers
console.log(window.NextDataLayer);
// Output: [{
// event: 'dl_add_to_cart',
// ecommerce: { items: [...], value: 99.99 },
// timestamp: 1234567890
// }]
console.log(window.dataLayer);
// Output: [{
// event: 'add_to_cart',
// ecommerce: { items: [...], value: 99.99 }
// }]

Use the status API to verify providers are loaded and events are being tracked.

const status = window.NextAnalytics.getStatus();
console.log('Events tracked:', status.eventsTracked);
console.log('Providers:', status.providers);
{
eventsTracked: 42,
providers: ['GTM', 'Facebook', 'RudderStack', 'Custom'],
debugMode: true,
ignoreMode: false
}

This tells you:

  • eventsTracked: Total number of events processed in this session
  • providers: List of active providers receiving events
  • debugMode: Whether debug logging is enabled
  • ignoreMode: Whether tracking is temporarily disabled

Each provider has different debugging tools and verification methods. Use the appropriate tab for your provider.

First, verify that all expected providers are connected and receiving events:

// Enable debug mode to see detailed logs
window.NextAnalytics.setDebugMode(true);
// Track a test event
next.trackAddToCart('123', 1);
// Console will show detailed output:
// [NextDataLayer] Event pushed: dl_add_to_cart
// [GTM] Pushing to dataLayer
// [Facebook] Tracking AddToCart
// [RudderStack] Tracking Product Added
// [Custom] Batching event (1/10)

Google Tag Manager Debugging

// Check if GTM container loaded
console.log('GTM loaded:', typeof window.dataLayer !== 'undefined');
// View all events in dataLayer
console.log(window.dataLayer);
// Check Elevar data layer (if using Elevar)
console.log(window.ElevarDataLayer);

Verification in GTM:

  1. Go to your GTM container in preview mode
  2. Load your website and perform actions
  3. The GTM preview panel should show events being fired
  4. Check that events match your expected naming convention

Common GTM Issues:

  • Events not appearing in preview mode
  • Incorrect event names or properties
  • Missing custom variables in GTM
  • Events firing after GTM container loads

Common analytics problems and solutions:

IssueCauseSolution
No events in any providerAnalytics not initializedVerify SDK loads before tracking events; check debug config
GTM not receiving eventsContainer loads after tracking eventsEnsure GTM tag loads before SDK initialization
Facebook showing duplicate purchasesSame event tracked twice or storeName conflictRemove duplicate tracking calls; configure storeName if using multiple pixels
RudderStack events not sentSDK not ready when events trackedSDK waits 5 seconds for RudderStack to load; verify endpoint configuration
Custom webhook 429 errorsSending too many requests per secondIncrease batchIntervalMs (default 3000ms) or reduce batchSize (default 10)
Events in dataLayer but not in providerProvider script not loadedVerify provider scripts load and initialize before analytics events
Debug logs not showingDebug mode disabledEnable with window.NextAnalytics.setDebugMode(true)
?ignore=true not workingSession already processing eventsClear ignore with window.NextAnalyticsClearIgnore() and refresh page
Missing event propertiesInsufficient context dataVerify event context (user, page, cart) populated before tracking
Provider not in status listProvider configuration disabledCheck analytics config for provider enabled: true setting

If a specific provider isn’t receiving events, follow this debugging process:

const status = window.NextAnalytics.getStatus();
console.log('Active providers:', status.providers);

If your provider isn’t in the list, check your configuration to ensure it’s enabled.

window.NextAnalytics.setDebugMode(true);

Now track an event and watch the console for debug output related to your provider.

Some events may be intentionally blocked from certain providers:

// Check GTM blocked events as an example
const config = window.nextConfig.analytics.providers.gtm;
console.log('Blocked events:', config.blockedEvents);

Verify the event you’re testing isn’t in the blocked list.

Check that the provider’s JavaScript library loaded successfully:

// Google Tag Manager
console.log('GTM loaded:', typeof window.dataLayer !== 'undefined');
// Facebook Pixel
console.log('Facebook loaded:', typeof window.fbq !== 'undefined');
// RudderStack
console.log('RudderStack loaded:', typeof window.rudderanalytics !== 'undefined');

If any of these return false or undefined, the provider script didn’t load. Check your configuration and network requests.

Events sent from your site may not appear in your analytics platform’s dashboard. Use provider-specific debugging tools:

  1. Open your GTM container
  2. Click Preview to enter preview mode
  3. Visit your website in a new tab
  4. The GTM preview panel will show all tags and events firing in real-time
  5. Click on events to see their properties and which tags they trigger
  1. Install the Facebook Pixel Helper extension
  2. Click the extension icon to view all pixel events
  3. Verify event names match your Facebook Catalog
  4. Check event properties like value and currency are correct
  5. Use the Diagnostics tab to identify validation issues
  1. Check RudderStack’s web console for errors
  2. Open DevTools Network tab and filter for RudderStack API calls
  3. Verify the destination is receiving events in your RudderStack workspace
  4. Check that your destination transformation rules are correct

Custom: Server Logs and Network Monitoring

Section titled “Custom: Server Logs and Network Monitoring”
  1. Check your server logs for incoming webhook requests
  2. Verify request headers and payload structure match your spec
  3. Check response codes (200-299 = success, 4xx/5xx = error)
  4. Monitor Network tab in DevTools for request timing and failures

Verify your analytics implementation before going live:

  • Debug mode enabled - window.NextAnalytics.setDebugMode(true) shows detailed logs
  • All providers active - window.NextAnalytics.getStatus() lists all expected providers
  • Events in data layer - console.log(window.NextDataLayer) shows events
  • GTM receiving events - console.log(window.dataLayer) contains your events
  • GTM preview mode - Events appear in GTM container preview panel
  • Facebook Pixel Helper - Extension shows purchase and add-to-cart events
  • RudderStack events - Network tab shows POST requests to RudderStack
  • Custom webhook - Server receives POST requests with event payloads
  • Event properties complete - All required fields present (value, currency, items)
  • No blocked events - Verify events aren’t in provider blockedEvents list
  • No duplicate events - Each action tracked once per provider
  • Ignore mode works - ?ignore=true prevents events from being tracked
  • Ignore mode clears - window.NextAnalyticsClearIgnore() resumes tracking
  • Status API responsive - getStatus() returns current state
  • Multiple providers tested - Events work across all enabled providers
  • Error handling - Failed provider requests don’t break site functionality
  • Production ready - Debug mode disabled in production config

After testing and debugging your analytics:

  1. Review Configuration - Check your provider settings match your platform setup
  2. Enable Tracking - Remove ?ignore=true and deploy to production
  3. Monitor Events - Use platform dashboards to monitor event flow
  4. Set Up Alerts - Configure monitoring for provider failures or dropped events
  5. Document Setup - Record your analytics configuration for your team

See the Configuration Guide for detailed provider setup instructions.