根据Google的指示,如何将Google分析代码添加到php页面? [英] How to add Google analytics code to php pages, per Google's instruction?

查看:400
本文介绍了根据Google的指示,如何将Google分析代码添加到php页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Analytics给他们的代码添加到您的基于PHP的网站的指示是这样的:

PHP实现 - 可选
创建一个名为PHP analyticstracking.php并将其包含在每个PHP模板页面中,然后在开始标记后立即将以下行添加到每个模板页面:



他们的意思是将它包含在每个模板页面上?如何在您的模板页面上包含文件?



我认为单词Then后的说明是您将它添加到模板页面的方式。那是对的吗?谷歌是否真的有这样糟糕的作家,他们会写出这样的混乱冗余?我缺少什么?

解决方案

确保您的网页具有.php扩展名,并且您的服务器正在运行php。
然后,在每个页面上键入以下
php代码:

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

或者,如果您的分析文件放置在与网页不同的目录中:

 <?php include(some_directory / analyticstracking.php); ?> 

作为开始标记,它们表示< html>

这是一个例子:



HTML / PHP PAGE CODE :

 < html> 

<?php include(some_directory / analyticstracking.php); ?>

< head>

<! - - 您的头部内容在这里 - >

< / head>

< body>

<! - 您的身体内容在这里 - >

< / body>

< / html>

希望能帮助你...


The instructions Google Analytics gives for adding their code to your php based site reads like this:

"PHP Implementation- OPTIONAL Create a PHP file named "analyticstracking.php" with the code above and include it on each PHP template page. Then, add the following line to each template page immediately after the opening tag: "

What on earth do they mean by "include it on each template page"? How do you include a file on your template page?

I'm thinking that the instructions after the word "Then," are how you add it to your template page. Is that correct? Does Google really have such bad writers that they would write a confusing redundancy like that? What am I missing?

解决方案

Make sure that your pages have ".php" extension and that your server is running php. Then, on each page type the following php code:

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

Or if your analytics file is placed in different directory than your pages:

<?php include("some_directory/analyticstracking.php"); ?>

As opening tag they mean the <html> tag at the top of the code.

Here is an example:

HTML/PHP PAGE CODE:

<html>

<?php include("some_directory/analyticstracking.php"); ?>

<head>

<!-- your head content goes here -->

</head>

<body>

<!-- your body content goes here -->

</body>

</html>

Hope that helps you...

这篇关于根据Google的指示,如何将Google分析代码添加到php页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆