如何追踪损坏的链接及其重定向?
1.Yandex.Metrica
在Yandex.Metrica中跟踪损坏的链接和重定向,转到“访问者设置”。只需将此字符串放在计数器代码中:
params:window.yaParams||{ }});
此外,再将此JS代码放在404页面上的某个位置:
<script>
var url = document.location.pathname + document.location.search
var url_referrer = document.referrer;
var yaParams = {error404: {page: url, from: url_referrer}};
</script>
这里url – 是404页面的当前地址,url referrer是访问它的地址。这样,您不仅可以跟踪所有损坏的链接,还可以跟踪它们所在的页面。
2.Google Analytics
将此代码放在404页面上,跟踪重定向
<script>
ga(‘send’, ‘pageview’, ‘404.html?page=’+ document.location.pathname + document.location.search +’&from=’ + document.referrer);
</script>
其中document.location.pathname + document.location.search – 是网站上找不到的网页网址;
document.referrer – 用户重定向的页面的URL。
3.百度站长
在百度站长管理平台查看抓取异常选项,并下载对应的数据进行查看。
4.Google Search Console
在Google网站站长中使用“抓取” – “抓取错误” – “错误404”查找错误。