Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.
D

Google analytics

by DarcH, Last updated on 9 years ago in Official Core Support - 6
I wanted to add this code to my website, which is newer version of that which is already in the forum:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."wink;
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"wink);
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4711486-2"wink;
pageTracker._initData();
pageTracker._trackPageview();
</script>

How to modify it that it can work?
Open up /footer.php

Add this below row 14 (render_footer(false);):
?>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4711486-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<?php
Infusions & modifications for PHP-Fusion v7

http://www.redward.org
would it not be ' instead of "
No need.
Infusions & modifications for PHP-Fusion v7

http://www.redward.org
Oh silly me I completely forgot :) . But if i do that at the bottom of the page there is \n\n . Can I simply delete that in the footer.php? Here
echo '</body>\n</html>\n';
Use " instead of ' on the echo.
Infusions & modifications for PHP-Fusion v7

http://www.redward.org
i don't know what you mean
Not
echo '</body>\n</html>\n';

but
echo "</body>\n</html>\n";

Just some Guy
thanks
or, before echo "</body>\n</html>\n";
$google_analytics = <<<EOD
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4711486-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
EOD;
echo $google_analytics."\n";
I don't know! I don't know why I did it, I don't know why I enjoyed it, and I don't know why I'll do it again! Bart Simpson
@ lelebart,

Yours works for version 7 in case anyone else was wondering.
I put my code in the footer above
echo "</body>\n</html>\n";

This now also makes my site(s) W3C compliant as I had the google script in other pages and were throwing validation errors.
Now everything is fine and my site(s) are W3C compliant.
for v7 sites, i prefer to put "my" code into [root]/includes/footer_include.php
I don't know! I don't know why I did it, I don't know why I enjoyed it, and I don't know why I'll do it again! Bart Simpson
Hi.

Well i create the php file, put the script code in it, name it, and in footer_includes.php add the require_once line

and when i reload my page it shows me like only the news, no center, left, right panels, no header ...

What can be wrong?

I am using v7.

Can you attach your example ?
i13.tinypic.com/29zsl82.jpg
sure, here you are the footer_includes.php:
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2010 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: footer_includes.php
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/

//Add your custom include files for the footer here

//Google Analytics by lelebart
$google_analytics = <<<EOD
<script type="text/javascript">
//<![CDATA[
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
if (typeof(_gat) == 'object') {
   try {
   var pageTracker = _gat._getTracker("UA-4711486-2");
   pageTracker._trackPageview();
   } catch(err) {}
}
//]]>
</script>
EOD;
echo $google_analytics."\n";
?>

edit: place your google-tracker-code instead of UA-4711486-2
I don't know! I don't know why I did it, I don't know why I enjoyed it, and I don't know why I'll do it again! Bart Simpson
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You cannot download attachments in this forum.