StatCounter Troubleshooting | OpsBlu Docs

StatCounter Troubleshooting

Troubleshoot and debug StatCounter issues — common errors, data discrepancies, and step-by-step diagnostic procedures.

Overview

This guide helps you diagnose and fix common StatCounter tracking issues. Most problems fall into a few categories: installation errors, configuration mistakes, data delays, or browser/platform conflicts.

Quick Diagnostic Steps

  1. Verify code installation - Check page source for tracking code
  2. Check project ID - Ensure it matches your dashboard
  3. Wait adequate time - Allow up to 30 minutes for data
  4. Test in incognito - Rule out ad blockers and cache issues
  5. Check dashboard - Verify you're viewing the correct project

Installation Issues

No Tracking Code Found

Problem: Tracking code is not present on your pages.

How to Diagnose:

// Open browser console (F12) and run:
if (document.body.innerHTML.includes('statcounter')) {
  console.log('StatCounter code found');
} else {
  console.error('StatCounter code NOT found');
}

Common Causes:

  • Code not added to template
  • Added to wrong file
  • Removed during site update
  • Theme override
  • Plugin conflict

Solutions:

  1. Verify Code Placement:

    • Right-click page > View Page Source
    • Press Ctrl+F (Cmd+F on Mac)
    • Search for "statcounter"
    • Code should appear before </body>
  2. Check All Pages:

    • Test multiple pages on your site
    • Ensure code is in global template
    • Verify it appears on all page types
  3. WordPress-Specific:

    // Verify plugin is active
    // Go to Plugins > Installed Plugins
    // Look for "StatCounter"
    // Ensure status is "Active"
    
  4. Manual Installation:

    • Re-add code to footer template
    • Clear any caching
    • Republish/redeploy site

Code Loading But Not Executing

Problem: Code is present but _statcounter is undefined.

How to Diagnose:

// Browser console
setTimeout(function() {
  console.log(typeof _statcounter);
  // Should show 'object', not 'undefined'
}, 3000);

Common Causes:

  • JavaScript errors blocking execution
  • Script URL incorrect
  • Network blocking the script
  • Content Security Policy blocking

Solutions:

  1. Check Console for Errors:

    • Open DevTools (F12)
    • Go to Console tab
    • Look for red error messages
    • Fix any JavaScript errors
  2. Verify Script URL:

    <!-- Correct URL -->
    <script src="https://www.statcounter.com/counter/counter.js" async></script>
    
    <!-- Common mistakes -->
    <!-- Missing https:// -->
    <!-- Typo in domain name -->
    <!-- Wrong file path -->
    
  3. Check Network Tab:

    • DevTools > Network
    • Reload page
    • Find counter.js request
    • Status should be 200
    • If 404/403, check URL
    • If blocked, check CSP/firewall
  4. Content Security Policy:

    <!-- Add to CSP if needed -->
    <meta http-equiv="Content-Security-Policy"
      content="script-src 'self' https://www.statcounter.com; img-src 'self' https://c.statcounter.com;">
    

Duplicate Tracking

Problem: Same visit tracked multiple times.

How to Diagnose:

  • Check Recent Visitor Activity
  • Look for duplicate entries with same timestamp
  • View page source for multiple code instances

Common Causes:

  • Code in multiple locations
  • Multiple plugins installing code
  • Theme + manual installation
  • Tag manager + direct code

Solutions:

  1. Search for All Instances:

    # In page source, search for:
    # Count how many times 'sc_project' appears
    # Should only appear once
    
  2. Check Common Locations:

    • Theme footer.php
    • functions.php
    • Header injection
    • Tag manager
    • Plugins
  3. Remove Duplicates:

    • Keep only one installation method
    • Disable conflicting plugins
    • Remove manual code if using plugin

Tracking Code Visible on Page

Problem: StatCounter code or counter appears visibly on page.

How to Diagnose:

  • View your website
  • Look for visible code text or counter
  • Check visibility setting

Solutions:

  1. Invisible Mode:

    // Ensure this is set to 1
    var sc_invisible=1;
    
  2. Counter HTML Visible:

    • Code may be outside HTML tags
    • Ensure code is before </body>
    • Check for broken HTML structure
  3. Escape Special Characters:

    // In some CMS, escape quotes
    var sc_security=\"abcd1234\";
    

Data Collection Issues

No Data Appearing in Dashboard

Problem: Code is installed but no data in dashboard.

How to Diagnose:

  1. Verify Installation:

    // Console check
    if (typeof _statcounter !== 'undefined') {
      console.log('Loaded correctly');
      console.log('Project ID:', sc_project);
    }
    
  2. Check Project ID:

    • Compare ID in code vs. dashboard
    • Ensure you're viewing correct project

Common Causes:

  • Wrong project ID
  • Viewing wrong dashboard
  • IP address blocked
  • Normal processing delay
  • Ad blocker enabled

Solutions:

  1. Verify Project ID:

    // In your code
    var sc_project=12345678;
    
    // In dashboard URL
    // statcounter.com/project/?project_id=12345678
    // These MUST match
    
  2. Wait Adequate Time:

    • Initial data: Up to 24 hours
    • Regular updates: 5-30 minutes
    • Don't panic if not immediate
  3. Check IP Blocking:

    • Dashboard > Config > IP Blocking
    • Ensure your IP not blocked
    • Remove or add to exceptions
  4. Disable Ad Blocker:

    • Test in incognito mode
    • Disable browser extensions
    • Try different browser
  5. Clear Cache:

    # Clear browser cache
    # Hard refresh: Ctrl+Shift+R (Windows)
    # Hard refresh: Cmd+Shift+R (Mac)
    

Data Delayed or Incomplete

Problem: Some visits tracked, others missing.

Common Causes:

  • Ad blockers
  • Privacy browsers
  • JavaScript disabled
  • Network issues
  • Single page app not tracking routes

Solutions:

  1. Understand Coverage:

    • 25-40% of users use ad blockers
    • 2% have JavaScript disabled
    • Privacy browsers block tracking
    • This is normal, expected
  2. SPA Route Tracking:

    // For Single Page Apps
    router.afterEach(() => {
      if (typeof _statcounter !== 'undefined') {
        _statcounter.record_pageview();
      }
    });
    
  3. Check Timezone:

    • Dashboard > Config > Project Settings
    • Verify timezone is correct
    • Mismatch causes confusing reports

Wrong Statistics

Problem: Data doesn't match expectations.

Common Causes:

  • Timezone misconfiguration
  • Session timeout setting
  • Multiple projects confusion
  • Counting own visits

Solutions:

  1. Timezone Settings:

    • Config > Project Settings > Timezone
    • Set to your local timezone
    • or match server timezone
    • or match user timezone
  2. Exclude Own Visits:

    • Config > IP Blocking
    • Add your IP address
    • Add office/team IPs
  3. Session Timeout:

    • Config > Session Timeout
    • Default: 30 minutes
    • Adjust if needed
  4. Project Verification:

    • Ensure viewing correct project
    • Check project ID in URL
    • Match to website

Browser and Platform Issues

Not Working in Specific Browsers

Problem: Tracking works in some browsers, not others.

Common Causes:

  • Safari Intelligent Tracking Prevention
  • Firefox Enhanced Tracking Protection
  • Brave Shield blocking
  • Browser extensions

Solutions:

  1. Test Across Browsers:

    • Chrome
    • Firefox
    • Safari
    • Edge
    • Brave
  2. Check Privacy Settings:

    Safari:
    - Preferences > Privacy
    - Uncheck "Prevent cross-site tracking" (for testing)
    
    Firefox:
    - Options > Privacy & Security
    - Standard/Strict affects tracking
    
    Brave:
    - Settings > Shields
    - Controls tracking/ads
    
  3. Inform Users:

    • Modern browsers block trackers
    • This is expected behavior
    • Cannot be bypassed

Mobile Tracking Issues

Problem: Tracking works on desktop, not mobile.

Common Causes:

  • Mobile ad blockers
  • AMP pages without code
  • Mobile theme without code
  • JavaScript errors on mobile

Solutions:

  1. Test Mobile Directly:

    • Use actual mobile device
    • Don't rely on desktop responsive mode
    • Test iOS and Android
  2. Check Mobile Theme:

    • Ensure code in mobile template
    • Some sites have separate mobile themes
    • Verify both have tracking code
  3. AMP Pages:

    • StatCounter doesn't work on AMP
    • Implement alternative tracking
    • Or disable AMP
  4. Mobile Browser Console:

    iOS Safari:
    - Settings > Safari > Advanced > Web Inspector
    - Connect to Mac for debugging
    
    Android Chrome:
    - chrome://inspect
    - Debug via desktop Chrome
    

WordPress-Specific Issues

Common Problems:

  1. Plugin Conflicts:

    // Deactivate other analytics plugins
    // Test with only StatCounter active
    // Reactivate one by one to find conflict
    
  2. Theme Conflicts:

    • Switch to default theme temporarily
    • If works, issue is with theme
    • Contact theme developer
  3. Caching Plugins:

    • Clear all caches
    • Temporarily disable caching
    • Test tracking
    • Re-enable caching
  4. Security Plugins:

    • Some block analytics scripts
    • Whitelist statcounter.com
    • Check firewall settings

Configuration Issues

Downloads Not Tracked

Problem: File downloads not appearing in reports.

Diagnostic Steps:

  1. Dashboard > Config > Configure Stats
  2. Check if "Track Downloads" is enabled
  3. Verify file extensions in list

Solutions:

  1. Enable Download Tracking:

    • Config > Configure Stats
    • Toggle "Track Downloads" ON
    • Add file extensions (pdf, zip, etc.)
  2. Verify Link Format:

    <!-- Correct: Direct link to file -->
    <a href="/files/document.pdf">Download</a>
    
    <!-- Won't track: JavaScript download -->
    <a href="#"
    
    <!-- Won't track: Data blob -->
    <a href="data:application/pdf...">Download</a>
    
  3. Test Download:

    • Click download link
    • Wait 15 minutes
    • Check "Popular Downloads" report

Problem: External link clicks not recorded.

Solutions:

  1. Enable Exit Link Tracking:

    • Config > Configure Stats
    • Enable "Track Exit Links"
  2. Verify External Links:

    <!-- Tracked (external domain) -->
    <a href="https://external-site.com">Link</a>
    
    <!-- NOT tracked (same domain) -->
    <a href="/page">Link</a>
    <a href="https://yourdomain.com/page">Link</a>
    
  3. Allow Time to Process:

    • Data appears in 15-30 minutes
    • Check "Exit Links" report

Cross-Domain Tracking Not Working

Problem: Sessions break between domains.

Expected Behavior:

  • StatCounter doesn't link sessions across domains
  • This is normal, not a bug
  • Each domain = new session

Workarounds:

  1. Use Same Project ID:

    // On all domains, use identical code
    var sc_project=12345678;
    var sc_invisible=1;
    var sc_security="abcd1234";
    
  2. Accept Limitations:

    • Sessions will break
    • Referrer will show previous domain
    • Can't create unified user journeys
  3. Alternative Tools:

Debug Mode

Enable Debugging

Browser Console Debug:

// Check if loaded
console.log('StatCounter loaded:', typeof _statcounter !== 'undefined');

// Check configuration
console.log('Project ID:', typeof sc_project !== 'undefined' ? sc_project : 'Not set');
console.log('Invisible:', typeof sc_invisible !== 'undefined' ? sc_invisible : 'Not set');

// Monitor tracking calls
if (typeof _statcounter !== 'undefined' && _statcounter.record_pageview) {
  var original = _statcounter.record_pageview;
  _statcounter.record_pageview = function() {
    console.log('StatCounter pageview fired');
    return original.apply(this, arguments);
  };
}

Network Monitoring

Track Network Requests:

  1. Open DevTools (F12)
  2. Go to Network tab
  3. Filter: statcounter
  4. Reload page
  5. Look for:
    • counter.js (should be 200 OK)
    • Image pixel request (tracking beacon)

Test Mode

Create Test Page:

<!DOCTYPE html>
<html>
<head>
  <title>StatCounter Test</title>
</head>
<body>
  <h1>StatCounter Test Page</h1>
  <p>If tracking works, this visit will appear in dashboard.</p>

  <!-- Your StatCounter Code -->
  <script type="text/javascript">
  var sc_project=12345678;
  var sc_invisible=1;
  var sc_security="abcd1234";
  </script>
  <script type="text/javascript"
  src="https://www.statcounter.com/counter/counter.js" async></script>

  <!-- Debug Script -->
  <script>
  window.addEventListener('load', function() {
    setTimeout(function() {
      if (typeof _statcounter !== 'undefined') {
        document.body.innerHTML += '<p style="color:green;">✓ StatCounter loaded successfully</p>';
        console.log('StatCounter object:', _statcounter);
      } else {
        document.body.innerHTML += '<p style="color:red;">✗ StatCounter failed to load</p>';
      }
    }, 3000);
  });
  </script>
</body>
</html>

Common Error Messages

"Invalid Project ID"

Cause: Project ID in code doesn't match any project in your account.

Solution:

  1. Log in to StatCounter
  2. Go to your project
  3. Check project ID in URL or settings
  4. Update code with correct ID

"Security Code Mismatch"

Cause: Security code incorrect or changed.

Solution:

  1. Dashboard > Config > Reinstall Code
  2. Copy fresh code with current security code
  3. Replace old code with new code

"Quota Exceeded"

Cause: Free plan visitor limit reached.

Solution:

  1. Upgrade to paid plan
  2. Or wait for next billing cycle
  3. Or reduce tracked pages

Advanced Troubleshooting

Compare with Other Analytics

If StatCounter shows different numbers than Google Analytics:

This is Normal:

  • Ad blocker rates differ
  • Counting methods differ
  • Bot filtering differs
  • Session definitions differ

What to Check:

  • Both tracking correctly?
  • Similar ballpark numbers?
  • Consistent trends?
  • No duplicate tracking?

Server Logs vs StatCounter

Server logs show more traffic because:

  • Bots make server requests
  • Ad blockers don't block server
  • JavaScript failures don't affect server
  • Crawlers hit server

StatCounter shows less because:

  • Only counts JavaScript execution
  • Blocked by ad blockers
  • Privacy browsers block
  • This is accurate human traffic

Validation Checklist

Run through this checklist:

  • Code present on all pages
  • Project ID correct
  • Security code matches
  • No JavaScript errors
  • Not blocked by ad blocker (test in incognito)
  • Network requests successful
  • Waited 24 hours for initial data
  • Viewing correct project
  • Timezone set correctly
  • IP not blocked

Getting Help

Before Contacting Support

Gather this information:

  1. Your website URL
  2. Project ID
  3. Screenshot of dashboard
  4. Page source showing code
  5. Browser console screenshot
  6. Network tab screenshot
  7. Description of issue
  8. Steps to reproduce

StatCounter Support

Free Users:

  • Knowledge Base
  • FAQs
  • Community Forum

Paid Users:

  • Email support
  • Priority response
  • Technical assistance

Support Resources

Quick Reference Table

Issue Quick Fix
No data after 24hrs Verify project ID, check code placement
Code not loading Check console errors, verify script URL
Duplicate tracking Remove duplicate code instances
Downloads not tracked Enable in Config > Configure Stats
Mobile not working Verify code in mobile template
Wrong stats Check timezone, exclude own IP
Ad blocker blocking Expected, test in incognito
SPA not tracking Add manual pageview calls on route changes
Cross-domain issues Use URL parameters, accept limitations
Data delayed Normal up to 30 minutes, wait patiently