Page 1 of 1

INCLUDING JAVASCRIPT/HTML IN PHP

Posted: Mon Apr 28, 2008 10:22 pm
by arielpv1
This is my short index.php site. It's a URL rotator.
It is http://www.mysite.com/index.php

Code: Select all

<?php
 
$version = "v1.01";
 
$linksfile ="urlrotator.txt";
 
$urls = file("$linksfile");
$url = rand(0, sizeof($urls)-1);
 
$goto = "$urls[$url]";
 
header("Location: $goto");
 
?>

urlrotator.txt contains: (http://www.mysite.com/page1.html and http://www.mysite.com/page2.html )

I want to add google analytics to http://www.mysite.com/index.php

I'm supposed to add the <script... JAVASCRIPT </script>... immediately before the </body> tag. That's what google analytics tells me. Where would I add that and how? is it possible?

Thanks!! :)

Re: INCLUDING JAVASCRIPT/HTML IN PHP

Posted: Mon Apr 28, 2008 11:05 pm
by Chris Corbyn
There's no need to post the same message four times. I've removed all your duplicates.

Re: INCLUDING JAVASCRIPT/HTML IN PHP

Posted: Mon Apr 28, 2008 11:16 pm
by John Cartwright
POSTING IN CAPS IS NOT COOL. :?

Re: INCLUDING JAVASCRIPT/HTML IN PHP

Posted: Tue Apr 29, 2008 12:11 am
by arielpv1
I'm sorry.

Re: INCLUDING JAVASCRIPT/HTML IN PHP

Posted: Tue Apr 29, 2008 12:25 am
by nowaydown1
Your index file doesn't appear to have any markup in it at all which complicates things a bit. Two things come to mind. I'm not sure how successful either of these will be for you. You could use try to using output buffering (php.net/ob_start) and just shove your script tag inline before your header redirect, or try to stick the script tag in both of your rotating files.

Re: INCLUDING JAVASCRIPT/HTML IN PHP

Posted: Tue Apr 29, 2008 12:04 pm
by RobertGonzalez
Find the part of your app that displays the footer portion of your markup (wherever the closing body tag is) and include the analytics code there.

If there is more than one file that contains your footer markup then you may want to consider consolidating your markup into single files containing the unchanging portions.