Hi,
I'm new to this forum and to the concept PHP as well.
I'm trying to use google analytic tracking code in my php site, but I don't know how to do so as I have worked with html pages all these days. The thing is, if I open the source page in any browser it shows <html> tags and other tags like head, title, keywords, body....but when I open through web server I can only see php files staring with <?php.....
Could any of you help me in implementing the analytic code in my pages created with PHP? Thank you so much!
Google analytic for PHP Pages
Moderator: General Moderators
Re: Google analytic for PHP Pages
Your sever isn't configured correctly if you are seeing the <?php tags and the code. This means your server isn't recognizing your php and running it.
When the server is configured correctly the following file:
when viewed via your server with your browser will look like[text]<html>
<b>Hello World!</b>
</html>[/text]Talk to your service provider, or if you set it up, you'll need to fix the install for Apache or Microsoft because it isn't running.
When the server is configured correctly the following file:
Code: Select all
<html>
<?php echo "<b>Hello World!</b>"; ?>
</html>
<b>Hello World!</b>
</html>[/text]Talk to your service provider, or if you set it up, you'll need to fix the install for Apache or Microsoft because it isn't running.
Re: Google analytic for PHP Pages
Hi Eric,
Thank you for your kind reply! I'm not familiar with PHP or accessing a server but only a little bit i know.
If the pages are not recognized how are all that pages in live online?
So, can I add <html> in all the pages that start with <?php..?
Could you please elaborate on how do I fix this up all by myself? Thanks for all your help! I appreciate it.
Thank you for your kind reply! I'm not familiar with PHP or accessing a server but only a little bit i know.
If the pages are not recognized how are all that pages in live online?
So, can I add <html> in all the pages that start with <?php..?
Could you please elaborate on how do I fix this up all by myself? Thanks for all your help! I appreciate it.
Eric! wrote:Your sever isn't configured correctly if you are seeing the <?php tags and the code. This means your server isn't recognizing your php and running it.
When the server is configured correctly the following file:when viewed via your server with your browser will look like[text]<html>Code: Select all
<html> <?php echo "<b>Hello World!</b>"; ?> </html>
<b>Hello World!</b>
</html>[/text]Talk to your service provider, or if you set it up, you'll need to fix the install for Apache or Microsoft because it isn't running.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Google analytic for PHP Pages
That's how PHP works, it's a server-side language. The server processes the PHP before sending it to the browser for display. The file doesn't need to start with <?php though: it just needs to surround any PHP code in the page. For example:macmachi wrote:The thing is, if I open the source page in any browser it shows <html> tags and other tags like head, title, keywords, body....but when I open through web server I can only see php files staring with <?php.....
Code: Select all
<html>
<head>
<title><?php echo 'Blah blah' . $current_page; ?></title>
</head>
<body><?php
echo 'something <strong>else</strong>';
?>
</body>
</html>Code: Select all
<html>
<head>
<title>Blah blah foo</title>
</head>
<body>something <strong>else</strong>
</body>
</html>Re: Google analytic for PHP Pages
Thanks Jonah for letting me know of that.
Can you please show some light on my query?
I see all the pages open with <?php and ends with </html> where is the opening tag <html> ? I don't find the opening tag in any of the source files.
Secondly, where do I put the tracking code????? please help.
Can you please show some light on my query?
I see all the pages open with <?php and ends with </html> where is the opening tag <html> ? I don't find the opening tag in any of the source files.
Secondly, where do I put the tracking code????? please help.
[/quote]That's how PHP works, it's a server-side language. The server processes the PHP before sending it to the browser for display. The file doesn't need to start with <?php though: it just needs to surround any PHP code in the page. For example:Will come out like this (providing $current_page has been set to " foo"):Code: Select all
<html> <head> <title><?php echo 'Blah blah' . $current_page; ?></title> </head> <body><?php echo 'something <strong>else</strong>'; ?> </body> </html>Code: Select all
<html> <head> <title>Blah blah foo</title> </head> <body>something <strong>else</strong> </body> </html>
Re: Google analytic for PHP Pages
I solved the prob through a PHP developer we recently hired. Thank you Eric and Jonah for answering my question. Cheers!