php网站上的Google Analytic?

时间:2011-10-27 18:47:25

标签: php google-analytics

我有一些问题需要让Google Analytics运行。我有一个analyticsTracking.php文件,它包含在我的index.php页面上,如下所示:

<?php
include("begin.php");
include($subroot . "templateconfig.php");
include($cms['tngpath'] . "genlib.php");
include($cms['tngpath'] . "getlang.php");
include($cms['tngpath'] . "$mylanguage/text.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;
include($cms['tngpath'] . "checklogin.php");

//Insert the following lines in your index.php to take advantage of template switching
if($templateswitching && $templatenum) {
include($cms['tngpath'] . "templates/template$templatenum/index.php");
exit;
}
//end of lines to be inserted for template switching

$flags['noicons'] = true;
$flags['noheader'] = true;
tng_header( $text['mnuheader'], $flags );
?>

<!-- "Home Page" (the text for these messages can be found at near the bottom of text.php -->
<h1><?php echo $text['mnuheader']; ?></h1>



<p><strong>Please customize this page!</strong></p> 

<?php include ("analyticsTracking.php"); ?>
</body>
</html>

在查看已生成的index.html时,根本没有来自analyticsTracking.php的数据?为什么呢?

请注意,我不使用PHP,所以这对我来说都是新的。

编辑1:抱歉,我使用的是index.php,而不是index.html。

Edit2: analyticsTracking.php包含以下内容:

<script type="text/javascript">
var gaJsHost = ((" https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
</script> <?php
// End Analytics tracking code
?>

2 个答案:

答案 0 :(得分:1)

因此,如果我理解正确,您的index.php脚本包含analyticsTracking.php,但是当您在浏览器中查看index.php时,您没有看到analyticsTracking.php中的任何HTML。

<?php include ("analyticsTracking.php"); ?>

这是正确的道路吗? analyticsTracking.php与index.php在同一目录中吗?尝试将include更改为require并查看在刷新网页时是否输出错误。

答案 1 :(得分:1)

抱歉,问题是我使用了错误的php文件。它正在按预期工作。