Google Sites is Google's no-code website builder integrated into Google Workspace. It is one of the most restrictive platforms for analytics because you cannot inject custom JavaScript, edit HTML directly, or access any server configuration. Analytics integration is limited to Google's own built-in GA connection and embed widgets.
Google Sites-Specific Debugging Approach
Since Google Sites provides no code-level access, debugging is entirely through the Google Sites editor and browser-based inspection.
Verify Built-in Analytics Integration
Google Sites has a native Google Analytics integration. This is the only supported method:
- Open your Google Site in edit mode
- Click the Settings gear icon (top right)
- Select Analytics
- Check if a Google Analytics Measurement ID (G-XXXXXXX) is entered
- Click Publish after any changes — unpublished changes will not include the tracking code
// In browser console on the published site, verify GA loaded
console.log('GA loaded:', typeof gtag === 'function');
console.log('dataLayer:', window.dataLayer?.length || 0, 'events');
// Check for the GA script tag
const gaScript = document.querySelector('script[src*="gtag"]');
console.log('GA script:', gaScript ? gaScript.src : 'NOT FOUND');
Check Published vs. Draft State
Google Sites only includes analytics on the published version. The editing preview does not load analytics:
// Detect if you're viewing the published or draft version
const isPublished = !window.location.hostname.includes('sites.google.com/u/');
console.log('Published version:', isPublished);
Most Common Google Sites Analytics Issues
1. Analytics Not Appearing After Adding Measurement ID
Symptoms: You entered the GA4 Measurement ID in Settings > Analytics but no data appears in Google Analytics.
Root cause: The site was not republished after adding the analytics ID. Google Sites requires an explicit publish action for analytics changes to take effect.
Fix: Click the Publish button (top right of the editor). Wait 5-10 minutes for Google's CDN to propagate the change, then verify on the published URL.
2. Google Workspace Domain Policy Blocking Analytics
Symptoms: The Analytics section in Settings is grayed out or missing entirely.
Root cause: Google Workspace administrators can restrict Google Sites features at the organization level. Your Workspace admin may have disabled the analytics integration.
Diagnosis: Check with your Google Workspace administrator. The setting is in: Admin Console > Apps > Google Workspace > Sites > Analytics > Allow users to add Google Analytics tracking
Fix: Request that your Workspace admin enable the analytics setting for your organizational unit.
3. Custom Domain Tracking Issues
Symptoms: Analytics works on the default sites.google.com/view/your-site URL but not on your custom domain.
Root cause: Google Sites custom domain setup involves DNS CNAME records. During propagation, some visitors may reach the sites.google.com URL while others reach the custom domain. The GA property may only be configured for one.
Fix: GA4 automatically handles both hostnames. Verify in GA4 by checking:
- Admin > Data Streams > Web > your stream > check "Website URL"
- Ensure the stream's domain matches your custom domain
- GA4's enhanced measurement should track both hostnames automatically
4. Embed Widget Not Supporting Custom Analytics
Symptoms: You embedded a third-party analytics tool via an embed widget but it does not load or loads with errors.
Root cause: Google Sites embed widgets use sandboxed iframes. Third-party scripts loaded inside embeds are isolated from the main page and cannot access the parent document or set cookies.
Diagnosis:
// Check if embeds are sandboxed
document.querySelectorAll('iframe').forEach((f, i) => {
console.log(`Embed #${i}:`, f.src?.substring(0, 60), '| sandbox:', f.sandbox?.value || 'none');
});
Fix: You cannot use embed widgets for analytics on Google Sites. The built-in GA integration is the only reliable tracking method. For other analytics platforms (Meta Pixel, LinkedIn Insight, etc.), Google Sites does not provide a supported injection method.
5. Single-Page Navigation Not Generating Pageviews
Symptoms: Only one pageview per session even when visitors navigate between pages.
Root cause: Google Sites uses client-side navigation between pages without full page reloads. The built-in GA integration should handle this, but misconfigurations can cause it to miss navigations.
Diagnosis:
// Monitor navigation events
let pageCount = 0;
const origPush = history.pushState;
history.pushState = function() {
origPush.apply(this, arguments);
pageCount++;
console.log('Navigation #' + pageCount + ':', arguments[2]);
};
Fix: Ensure you are using a GA4 Measurement ID (G-XXXXXXX), not a legacy Universal Analytics ID (UA-XXXXXXX). GA4's enhanced measurement automatically tracks history-based navigation. Universal Analytics does not.
Environment Considerations
- No custom JavaScript: Google Sites does not allow any custom script injection. The embed widget sandboxes all third-party content
- No server access: Google Sites is fully hosted by Google. There are no configuration files, CDN settings, or caching controls
- Google CDN: Published sites are served through Google's CDN. Cache invalidation after publishing can take 5-15 minutes
- GA4 only: The built-in integration only supports Google Analytics 4. It does not support GTM, Meta Pixel, or any other third-party analytics platform
- Mobile responsive: Google Sites auto-generates mobile layouts. The same analytics code applies to both views
Performance Issues
- LCP Issues - Google CDN delivery and embedded content loading times
- CLS Issues - Layout shifts from embed widgets and auto-generated responsive layouts
Tracking Issues
- Events Not Firing - Debug unpublished changes, Workspace restrictions, and SPA navigation gaps
Related Resources
- Google Sites help center
- Global Issues Hub for platform-agnostic solutions