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

StackOverflow https://stackoverflow.com/questions/23621482

  •  21-07-2023
  •  | 
  •  

Вопрос

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top