大网数据广告活动
网站运营与故障问答

How to track usage of redirecting domains using either Google Analytics or server logs using Apache

· 52CE 我爱测

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-…

问题原文

原帖链接 · Blisteragent · CC BY-SA 3.0

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!

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 3.0

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 \"%{Referer}i\" \"%{User-Agent}i\" %v" combinedserver
CustomLog /var/log/apache2/access_log combinedserver

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。