我刚刚遇到了Google Analytics(分析)问题。我有一个使用php开发的网站。现在我想让我的网站变成非规范格式。我遵循以下编码。但谷歌分析仍然无法识别规范URL。Google Analytics(分析)中的Canonical URL问题
编码
<html>
<head>
<link rel="canonical" href="<?php $url="http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; echo $url;?>">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'Tracking ID']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<?php
if(isset($_REQUEST['id']))
{
echo $url;
}
?>
</body>
<html>
当我试图打印$网址它打印网址的规范格式。但它不被谷歌分析所认可。任何人都可以告诉我这个编码有什么问题?
您可以显示HTML是'<链接的rel =“规范“$ _ SERVER ['SCRIPT_NAME']; echo $ url;?>”>'产生?也许用example.com代替TLD – MonkeyZeus
我将id传递给这个文件。如果我将url设为http://example.com/canonical.php?id=10,则它会将规范形式设为http://example.com/canonical.php .. –
对不起,我并不完全了解您是什么直到现在,但它看起来像埃尔克Pierstorff知道什么 – MonkeyZeus