i want to add google analytics code into my site as follows <? <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-998977-1"; urchinTracker(); </script> ?> PHP: will this work? Thanks
Nope. Why are you surrounding it with PHP tags, when you should just insert it as normal HTML into the webpage. If it must be inserted via a PHP command, then use the echo or print commands to do so.
Here's an example of what cellularnews was talking about. This is the phoogle maps script. Notice how he uses $map->printGoogleJS(); to inject the google javascript code into his document. You could do something similar except put it somewhere in the body tag instead of the head tag. <?php /** * Showing 1 point with Phoogle Maps * class developed by Justin Johnson <justinjohnson@system7designs.com> */ require_once 'phoogle.php'; $map = new PhoogleMap(); $map->setAPIKey("ABQIAAAA0ksKqHM3yT_xmOPe0DANGRRMlCWGe88WcLmN582t1mFB9gpW6hTvRlzTS-LCJ8nFoD2AGi5vq0X-Yg"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <? $map->printGoogleJS(); ?> </head> <body> <? $map->addAddress('208 Dingler Ave, Mooresville, NC 28115'); $map->showMap(); ?> </body> </html> Code (markup):