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.
Not a member yet? Click here to register.
Forgot Password?

Google analytics

Asked Modified Viewed 12,290 times
D
DarcH
D
DarcH 10
  • Junior Member, joined since
  • Contributed 36 posts on the community forums.
  • Started 12 threads in the forums
  • Started this discussions
asked
Junior Member

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?
0 replies

13 posts

E
Elactos
E
Elactos 10
Infusions & modifications for PHP-Fusion v7
http://www.redward.org
  • Member, joined since
  • Contributed 138 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

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
Edited by Elactos on 15-06-2008 13:48,
0 replies
C
Craig
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
answered
Fusioneer

would it not be ' instead of "
0 replies
E
Elactos
E
Elactos 10
Infusions & modifications for PHP-Fusion v7
http://www.redward.org
  • Member, joined since
  • Contributed 138 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

No need.
0 replies
D
DarcH
D
DarcH 10
  • Junior Member, joined since
  • Contributed 36 posts on the community forums.
  • Started 12 threads in the forums
  • Started this discussions
answered
Junior Member

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';
0 replies
E
Elactos
E
Elactos 10
Infusions & modifications for PHP-Fusion v7
http://www.redward.org
  • Member, joined since
  • Contributed 138 posts on the community forums.
  • Started 5 threads in the forums
answered
Member

Use " instead of ' on the echo.
0 replies
D
DarcH
D
DarcH 10
  • Junior Member, joined since
  • Contributed 36 posts on the community forums.
  • Started 12 threads in the forums
  • Started this discussions
answered
Junior Member

i don't know what you mean
0 replies
H
HobbyMan
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
answered
Veteran Member

Not
echo '</body>\n</html>\n';

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

0 replies
D
DarcH
D
DarcH 10
  • Junior Member, joined since
  • Contributed 36 posts on the community forums.
  • Started 12 threads in the forums
  • Started this discussions
answered
Junior Member

thanks
0 replies
L
lelebart
L
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
  • Member, joined since
  • Contributed 133 posts on the community forums.
  • Started 21 threads in the forums
answered
Member

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";
0 replies
— 7 months later —
J
Joe Kriz
J
  • Senior Member, joined since
  • Contributed 281 posts on the community forums.
  • Started 39 threads in the forums
answered
Senior Member

@ 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.
0 replies
— 3 months later —
L
lelebart
L
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
  • Member, joined since
  • Contributed 133 posts on the community forums.
  • Started 21 threads in the forums
answered
Member

for v7 sites, i prefer to put "my" code into [root]/includes/footer_include.php
0 replies
— 1 year later —
A
Al_Capone
A
i13.tinypic.com/29zsl82.jpg
  • Junior Member, joined since
  • Contributed 19 posts on the community forums.
  • Started 5 threads in the forums
answered
Junior Member

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 ?
0 replies
L
lelebart
L
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
  • Member, joined since
  • Contributed 133 posts on the community forums.
  • Started 21 threads in the forums
answered
Member

sure, here you are the footer_includes.php:
<?php
/*-------------------------------------------------------+
| PHPFusion 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
Edited by lelebart on 18-05-2010 16:30,
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 13 posts
  • Votes 0 votes
  • Topic users 7 members

0 participants

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet