2022-01-30 | 1447 Print PDF
Are you having issues with your Google Analytics web traffic not showing your real web traffic counts because of a URL redirect issue? Then this post is for you, as we will be looking at the simple steps to rectify this warning and also get your website traffic capturing the redirects from the redundant hostnames to your primary hostname.
In most cases when you see the redundant hostnames error message on your Google Analytics dashboard, what this insinuates is that both URL versions of your domain name are not redirecting properly to the main primary hostname you have chosen to receive or direct web visitors to.
- www.yourdomain.com/redundant-hostnames-google-analytics
- yourdomain.com/redundant-hostnames-google-analytics
yourdomain.com does not redirect to https://www.yourdomain.com/
nor
www.yourdomain.com does not redirect to https://www.yourdomain.com/
There are some options being offered on your Google Analytics dashboard to fix these issues, and we are going to walk through them together.
So let's first start off with using the Google Analytics Filter to set up how it reads traffic from which URL;
Go to Admin
Click on the All Filters or the Filters Tab, Next click on Add filter button which should take you to a page similar to the image below.
Simply follow the steps below;
Configure the filter depending on how you want your hostname to appear.
- Converting WWW to non-www
- Filter Field: Hostname
- Search String: ^www.
- Replace String: leave it empty
- Converting non-www to WWW
- Filter Field: Hostname
- Search String: ^yourdomain.com$
- Replace String: www.yourdomain.com
After selecting the best option for you simply input them in the right reference as the image above then scroll down to Apply Filter to Views (select the view for your main web property ie yourdomain.com) and then click Save.
In effect, this will solve the redundant hostname in Google Analytics, however, your site will still have 2 separate URLs for each page, in other to fix that you might need to execute a 301 redirect via .htaccess.
A simple solution will be to use the following .htaccess 301 redirects on your .htaccess file, in our case, our redirects were all working fine but due to some web traffic requests to unspecified versions of our domain names, Google analytics started picking up redundant hostnames and splitting our web traffic among the two versions of our domain names instead of following the redirect protocols initiated on .htaccess.
RewriteEngine On RewriteBase / RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR] RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ RewriteRule .* https://www.yourdomain.com%{REQUEST_URI} [R=301,L] RewriteCond %{HTTPS} =on RewriteCond %{HTTP_HOST} ^yourdomain.com$ RewriteRule .* https://www.yourdomain.com%{REQUEST_URI} [R=301,L]
Secondly, if you run a WordPress Based website or Blog(s) you can apply the .htaccess code below to resolve your Google Analytics Redundant Hostname Warning: Open your website root .htaccess file and paste this code:
# BEGIN WordPress RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC] RewriteRule ^.*$ http://www.yourdomain.com%{REQUEST_URI} [R=301,L] RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress
Please note that you have to change "yourdomain" with your actual domain name.
Implementing this should correctly redirect all your domain versions to https://www.yourdomain.com, you can validate yourself via this tool.
I will also recommend the following informative reads on How to redirect HTTP to HTTPS Using .htaccess and How To 301 Redirect, (AVOID DUPLICATE CONTENT SEO).
Attention: Please note it takes 24hours before Google Analytics resolve Redundant Hostnames Error.
SEO Tips and Strategies For Small Businesses
Google is making a major change to Local Service Ads
Why is Google Ads So Expensive a Case Study
Meta Careers Remote Work From Home Jobs Scam
Strategies For Integrating Organic and Paid Web Site Traffic
How to use Google Analytics GA4 Reporting
Digital Marketing Agency Red Flags List
How To Grow Your Business Market Share Online
Different Types Of SEO Pricing Models
How To Improve Local SEO Search Results