How to track usage of redirecting domains using either Google Analytics or server logs using Apache
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about , , , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :My company utilizes numerous domains and TLDs that all end up pointing to one main domain. The domains include variations of the company name or its product items. For instance,domain.cc, domain.biz, domain.info, do-main.cc, do-main.biz, do-main.info, etc.
As the webmaster, I am tasked with tracking these domains and their usage to determine which are effective and which are not. At some point then I will have to determine which domains to let expire and which to renew.
How do I do this? I've looked at Google Analytics and it doesn't show me this data anywhere. I've looked at the server raw logs (Apache) and this too leaves off the requested TLD in the incoming URL. It was suggested to add a UTM parameter to my redirects in htaccess, but I'm not sure how that would be implemented. Suggestions? And thanks!
Redirecting with UTM parameters is a good way of doing it. See Can I track referral traffic in Google Analytics from a domain that is redirecting to my site?.
Here is a rewrite rule that should do the redirection and add the needed UTM parameters:
RewriteCond "%HTTP_HOST" "example.cc$" [NC,OR]
RewriteCond "%HTTP_HOST" "example.biz$" [NC,OR]
RewriteCond "%HTTP_HOST" "do-main.example.com$" [NC]
RewriteRule "^/?(.*)" "http://www.example.com/$1?utm_campaign=domainnames&utm_medium=domain&utm_source=%HTTP_HOST" [L,R=301,QSA]
If you are on IIS, we had somebody ask about how to implement it there: Track Google Analytics from a redirected domain using IIS
If you want to have Apache log them you can do so as well. I recommend turning on logging of the host name in Apache logs. I use the following log directives to append it to the end of the log file:
# Log format: combined logs with virtual host
LogFormat "%h %l %u %t "%r"" %>s %b ""%Refereri"" ""%User-Agenti"" %v"" combinedserverAdditionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.
Comments
Post a Comment