# Using Google Analytics with WordPress

> Add Google Analytics tracking to your WordPress site with a plugin or by adding the code to your theme.

Source: https://helpcenter.ruachost.com/wordpress/guides/using-google-analytics-with-wordpress/

**Google Analytics** provides detailed statistics about visitor traffic to your site. Integrating it with WordPress allows you to track user behavior, measure performance, and optimize content. On **ruachost.com**, you can enable Google Analytics in two main ways: using a plugin or editing your theme directly.

## Why Use Google Analytics?

- Understand visitor demographics and behavior.
- Track page views, bounce rates, and conversions.
- Measure the effectiveness of marketing campaigns.
- Improve SEO and content strategy.

## Methods to Enable Google Analytics

### Method 1: Use a WordPress Plugin

Plugins are the easiest way to add Google Analytics to WordPress.

1. Sign up for a **Google Analytics account** at analytics.google.com.
2. Obtain your **Tracking ID** (e.g., `UA-XXXXXXXXX-X`).
3. Install a plugin such as:

   - ### Google Analytics for WordPress
   - ### Google Analyticator
   - ### MonsterInsights
4. Enter your Tracking ID in the plugin settings.
5. Save changes and the plugin will automatically insert the tracking code into your site.

✅ **Pros:** Easy setup, no coding required. ⚠️ **Cons:** Plugins add processing overhead, which may slightly affect performance.

### Method 2: Edit the WordPress Theme

For more control, you can add the tracking code manually.

1. Sign up for a **Google Analytics account** and copy the tracking code snippet.
2. Log in to WordPress as an administrator.
3. Navigate to **Dashboard → Appearance → Editor**.
4. Open the `header.php` file.
5. Paste the tracking code just above the closing `</head>` tag.
6. Save changes.

⚠️ **Important:** If your theme is updated, these changes may be overwritten. To avoid this, use a **child theme** instead of editing the parent theme directly.

> **Note:**
- It can take up to **24 hours** for Google Analytics to change its status from *Tracking Not Installed* to *Receiving Data*.
- Always verify tracking is working by checking **Real‑Time Reports** in Google Analytics.
- Consider using **Google Tag Manager** for advanced tracking setups.
