Analytics Test
📊 Analytics Test Page
Real analytics testing
🔍 Real-Time Analytics Check
1. Google Analytics Test
Console Commands:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Check if gtag is loaded
console.log('gtag function:', typeof window.gtag);
// Check dataLayer
console.log('dataLayer:', window.dataLayer);
// Send test event manually
if (window.gtag) {
gtag('event', 'test_event', {
'event_category': 'engagement',
'event_label': 'manual_test',
'value': 1
});
console.log('Test event sent to Google Analytics');
}
// Check if GA is really working
if (window.gtag) {
gtag('config', 'G-BH9P4LY6E7', {
'custom_map': {'custom_parameter': 'test_value'},
'send_page_view': true
});
console.log('Page view sent to GA');
}
2. Microsoft Clarity Test
Console Commands:
1
2
3
4
5
6
7
8
9
10
11
// Check if clarity is loaded
console.log('Clarity function:', typeof window.clarity);
// Check clarity object
console.log('Clarity object:', window.clarity);
// Send test event manually
if (window.clarity) {
clarity('set', 'test_tag', 'analytics_test_page');
console.log('Test tag sent to Microsoft Clarity');
}
3. Network Tab Verification
Check these requests in Network tab:
- Google Analytics:
- URL:
https://www.google-analytics.com/g/collect
- Method: POST
- Should contain:
tid=G-BH9P4LY6E7
- URL:
- Microsoft Clarity:
- URL:
https://www.clarity.ms/collect
- Method: POST
- Should contain session data
- URL:
🚨 Troubleshooting Steps
Step 1: Force Manual Loading
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Force load Google Analytics manually
const script = document.createElement('script');
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-BH9P4LY6E7';
script.async = true;
script.onload = function() {
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-BH9P4LY6E7', {
'send_page_view': true,
'debug_mode': true
});
console.log('GA manually loaded and configured');
};
document.head.appendChild(script);
Step 2: Check Real-Time Reports
- Google Analytics: Go to Realtime → Overview
- Microsoft Clarity: Go to your Clarity dashboard
- Browse this page and check if visitor appears
Step 3: Debug Mode
1
2
3
4
5
6
7
// Enable GA debug mode
if (window.gtag) {
gtag('config', 'G-BH9P4LY6E7', {
'debug_mode': true,
'send_page_view': true
});
}
🎯 Test Actions
Click these buttons to generate events:
📱 Expected Results
✅ If Working:
- Network requests to
google-analytics.com/g/collect
- Network requests to
clarity.ms/collect
- Real-time visitors in GA dashboard
- Session data in Clarity dashboard
❌ If Not Working:
- No network requests
- Console errors
gtag
orclarity
undefined- No real-time data in dashboards
⚠️ Important
Real-time analytics may take 1-5 minutes to appear in dashboards. Check Network tab for immediate verification of data sending.