How to add Google analytics code to php pages, per Google's instruction?

…衆ロ難τιáo~ 提交于 2019-12-12 02:48:10

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/23621482/how-to-add-google-analytics-code-to-php-pages-per-googles-instruction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!