Skip to content

Add Google Analytics (or Tracking Codes) via SEOvault AI

SEOVault AI includes built-in Google Analytics integration, allowing you to add tracking codes to your site without additional plugins. This guide covers GA4 setup and custom tracking code options.

SEOVault AI supports two tracking methods:

The recommended method for Google Analytics 4. Uses the official gtag.js library from Google Tag Manager.

Features:

  • Official Google Analytics 4 implementation
  • Automatic pageview tracking
  • Event tracking support
  • IP anonymization option
  • Measurement ID configuration

For custom tracking implementations or other analytics services.

Features:

  • Full control over tracking code
  • Support for any analytics service
  • Raw JavaScript output
  • No library restrictions

Tracking is disabled by default. Enable it to start collecting analytics data.

To enable:

  1. Go to SEOvault AI > Analytics
  2. Check Enable Analytics Tracking
  3. Click Save Changes

Your GA4 Measurement ID (e.g., G-XXXXXXXXXX).

To find your Measurement ID:

  1. Go to Google Analytics
  2. Select your property
  3. Go to Admin > Data Streams
  4. Select your data stream
  5. Copy the Measurement ID

To configure:

  1. Go to SEOvault AI > Analytics
  2. Select gtag as the tracking method
  3. Enter your Measurement ID
  4. Click Save Changes

Anonymize IP addresses sent to Google Analytics for privacy compliance.

To enable:

  1. Go to SEOvault AI > Analytics
  2. Check Anonymize IP Addresses
  3. Click Save Changes

This adds the anonymize_ip parameter to the gtag config.

By default, tracking is disabled for logged-in users to exclude your own activity from analytics.

To track logged-in users:

  1. Go to SEOvault AI > Analytics
  2. Check Track Logged-in Users
  3. Click Save Changes

This is useful for:

  • Testing tracking on your own account
  • Monitoring admin activity
  • Sites with user-generated content

Use custom tracking code for:

  • Other analytics services (Matomo, Plausible, etc.)
  • Custom Google Analytics implementations
  • Tag manager containers
  • Advanced tracking configurations

To configure:

  1. Go to SEOvault AI > Analytics
  2. Select custom as the tracking method
  3. Paste your tracking code in the text area
  4. Click Save Changes

Example custom code:

// Matomo Analytics example
var _paq = window._paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.example.com/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();

The tracking code is automatically injected into your site’s <head> section:

  • Output location: wp_head hook (priority 99)
  • Output condition: Only when tracking is enabled
  • Logged-in user exclusion: Respects the “Track Logged-in Users” setting
  • No output on: admin pages, feeds, embeds, previews
<!-- Analytics Tracking -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX', {"anonymize_ip":true});
</script>
<!-- /Analytics Tracking -->

Enable IP anonymization to comply with privacy regulations like GDPR:

  • Masks the last octet of IPv4 addresses
  • Masks the last 80 bits of IPv6 addresses
  • Recommended for EU-based sites
  • Does not affect analytics accuracy significantly

By default, logged-in users are not tracked to:

  • Exclude your own activity from analytics
  • Prevent skewing of data
  • Maintain privacy for logged-in users
  • Focus on visitor behavior

Google Analytics data retention is managed in your Google Analytics account, not in the plugin. Configure data retention settings in Google Analytics Admin.

Using Google Analytics:

  1. Go to your Google Analytics property
  2. Go to Realtime > Overview
  3. Visit your site in a new browser or incognito window
  4. Verify your visit appears in the Realtime report

Using browser tools:

  1. Open your site in a browser
  2. Open Developer Tools (F12)
  3. Go to the Network tab
  4. Reload the page
  5. Look for requests to google-analytics.com or googletagmanager.com

View your page source to verify the tracking code is present:

  1. Right-click on your page
  2. Select View Page Source
  3. Search for “Analytics Tracking” or “gtag”
  4. Verify the code is present in the <head> section

If the tracking code is not in your page source:

  1. Verify tracking is enabled in settings
  2. Check that you’re not logged in (if “Track Logged-in Users” is disabled)
  3. Clear your cache if using a caching plugin
  4. Check for conflicts with other analytics plugins
  5. Verify the Measurement ID is correctly entered

If no data appears in Google Analytics:

  1. Verify the Measurement ID is correct
  2. Check that the property is receiving data in Realtime
  3. Verify your site is not blocking Google Analytics
  4. Check browser extensions that might block tracking
  5. Verify the tracking code is present in page source

If logged-in users are being tracked when they shouldn’t be:

  1. Verify “Track Logged-in Users” is unchecked
  2. Clear your cache
  3. Log out and log back in
  4. Check for other analytics plugins that might be tracking

If custom tracking code is not working:

  1. Verify the code is valid JavaScript
  2. Check for syntax errors
  3. Test the code in browser console
  4. Verify the tracking method is set to “custom”
  5. Check browser console for JavaScript errors

Google Analytics 4 (GA4) is the current standard:

  • Future-proof tracking
  • Enhanced measurement features
  • Better cross-platform tracking
  • Improved privacy controls

After configuring tracking:

  • Test with Realtime reports
  • Verify events are tracked
  • Check conversion tracking
  • Monitor data for 24-48 hours

Use filters in Google Analytics to exclude:

  • Your office IP address
  • Your home IP address
  • Development environments
  • Staging sites

Keep records of:

  • Measurement ID
  • Custom events configured
  • Filters applied
  • Goals and conversions

If migrating from Universal Analytics (UA):

  1. Create a GA4 property in Google Analytics
  2. Set up the GA4 Measurement ID in SEOvault AI
  3. Run both UA and GA4 in parallel during migration
  4. Update any custom event tracking to GA4 format
  5. Disable UA tracking after migration is complete