Back to Community

How to Fix Google Analytics Code Not Showing on Your WordPress Site

Content

One of the most common issues users face with the 'GA Google Analytics' plugin is that the tracking code doesn't appear on their site, even after correctly entering their GA Tracking ID. This means no data is being sent to Google Analytics, making the plugin useless. Let's explore why this happens and how to fix it.

Why Your Tracking Code Isn't Showing

Based on community reports, this problem typically occurs for one of a few key reasons:

  • Missing wp_head() tag: The plugin relies on your WordPress theme's wp_head() function hook to output the tracking code in the <head> section. If your theme is missing this essential tag, the code cannot be inserted.
  • Plugin or Theme Conflict: Another plugin, or sometimes the theme itself, can interfere with the normal output of the tracking code.
  • Incorrect Code Placement: Attempting to add complex code, like PHP snippets or full <script> tags, in the wrong plugin field can prevent the core tracking code from loading correctly.

How to Troubleshoot and Fix the Issue

1. Check for the wp_head() Tag

This is the first and most critical step. View your website's source code (right-click on your page and select 'View Page Source'). Search for wp-head. If you can't find it, your theme is likely missing the required <?php wp_head(); ?> tag just before the closing </head> tag. You will need to add this to your theme's header.php file. Warning: Editing theme files directly is not recommended; consider using a child theme.

2. Perform a Conflict Test

To rule out a conflict with another plugin or your theme, follow these steps:

  1. Temporarily switch to a default WordPress theme like Twenty Twenty-Four.
  2. Clear your browser and site cache.
  3. Check if the GA tracking code now appears in your page source. If it does, the issue is with your original theme.
  4. If the code is still missing, disable all other plugins except 'GA Google Analytics'.
  5. Check your site again. If the code appears, reactivate your plugins one-by-one, checking after each, to identify the conflicting plugin.

3. Verify Your Plugin Settings

Ensure you are not accidentally breaking the code output:

  • Custom Code Field: The 'Custom GA Code' field is for JavaScript only. Do not wrap code in <script> tags, as the plugin adds these automatically. Adding them yourself can cause errors.
  • PHP Code: The plugin's text fields cannot execute PHP code. Any PHP snippets added will be stripped out when saved.
  • AdWords/Conversion Code: If you've added additional code for AdWords or other purposes, ensure it is formatted correctly and does not contain errors that would halt script execution.

Checking for Success

After making these changes, always view your website's page source again and search for your GA Tracking ID (e.g., UA- or G-) to confirm the code is now present and correct.

By methodically working through these common causes, you should be able to resolve the issue and get your Google Analytics tracking back on track. If problems persist, the broader community on independent forums like this one can often help if you provide details about your setup and what steps you've already tried.

Related Support Threads Support