W

WordPress Integration

Add theBizness.ai analytics to your WordPress site with multiple installation methods.

Setup Time

2 minutes

Difficulty

Easy

Performance

Optimized

Choose Your Installation Method

functions.php Method
Add tracking code through your theme's functions.php file (recommended)

Basic Implementation

Add this code to your active theme's functions.php file:

// Add to your theme's functions.php file
function add_thebizness_analytics() {
    // Only load on frontend
    if (is_admin()) {
        return;
    }
    
    $website_id = 'your-website-id';
    $domain = get_site_url();
    
    // Remove protocol from domain
    $domain = preg_replace('(^https?://)', '', $domain);
    
    echo '<script async defer data-website-id="' . esc_attr($website_id) . '" data-domain="' . esc_attr($domain) . '" src="https://thebizness.ai/js/script.js"></script>';
}
add_action('wp_head', 'add_thebizness_analytics');

Enhanced with Configuration

For better security and flexibility, use this enhanced version:

// Enhanced version with environment variables
function add_thebizness_analytics() {
    if (is_admin()) {
        return;
    }
    
    // Get from wp-config.php constants or WordPress options
    $website_id = defined('THEBIZNESS_WEBSITE_ID') ? THEBIZNESS_WEBSITE_ID : get_option('thebizness_website_id');
    $domain = defined('THEBIZNESS_DOMAIN') ? THEBIZNESS_DOMAIN : get_site_url();
    
    if (empty($website_id)) {
        return; // Don't load if not configured
    }
    
    // Clean domain
    $domain = preg_replace('(^https?://)', '', $domain);
    
    echo '<script async defer data-website-id="' . esc_attr($website_id) . '" data-domain="' . esc_attr($domain) . '" src="https://thebizness.ai/js/script.js"></script>';
}
add_action('wp_head', 'add_thebizness_analytics');

Add to wp-config.php

// Add to wp-config.php (above the "That's all, stop editing!" line)
define('THEBIZNESS_WEBSITE_ID', 'your-website-id');
define('THEBIZNESS_DOMAIN', 'yourdomain.com');
Why functions.php?
  • • Automatically excludes admin pages
  • • Works with all themes and updates
  • • Can be configured via wp-config.php
  • • Easy to remove if needed
Verify Installation
Make sure analytics are working on your WordPress site

✅ Frontend Check

  1. 1. Visit your website (not admin area)
  2. 2. Right-click → Inspect Element
  3. 3. Go to Network tab in DevTools
  4. 4. Refresh and look for script.js

📊 WordPress Specific

  1. 1. Test on different post types (posts, pages)
  2. 2. Check category and archive pages
  3. 3. Verify script NOT loading in admin area
  4. 4. Test with caching plugins active
Common WordPress Issues
  • • Clear all caching plugins after installation
  • • Some security plugins may block external scripts
  • • Make sure you're testing on frontend, not admin
  • • Check for theme conflicts in customizer preview

🎉 WordPress Analytics Active!

Your WordPress site is now tracking visitor analytics. Here's what to explore next:

🛒 WooCommerce

Track e-commerce sales and customer journeys

📝 Content Analytics

See which posts and pages perform best

🎯 UTM Campaigns

Track marketing campaigns and referrals