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....Cannot get it to work

Asked Modified Viewed 2,618 times
P
ps2cho
P
ps2cho 10
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
asked
Junior Member

I've tried so many different things at getting it to work and it just fails.

Either A) Page gives "ERROR ON LINE"

or B) Google is not showing stats update.

Can someone who HAS IT WORKING post HOW?

Thanks!!
0 replies

8 posts

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

No one can help you without a site link and/or you post the relevant code.
0 replies
P
ps2cho
P
ps2cho 10
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
answered
Junior Member

the site is www.w124-zone.com

footer.php in /themes/templates:

echo "<script type='text/javascript' src='".INCLUDES."analytics.js'></script>\n";


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


-----

analytics.js:

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]var _gaq = _gaq || [];_gaq.push(['_setAccount', 'UA-192336blah']);_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);})();[/syntaxhighlighter]
Edited by HobbyMan on 13-12-2010 00:14,
0 replies
P
ps2cho
P
ps2cho 10
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
answered
Junior Member

I have also tried just putting the code from google straight into the footer.php....

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1923blah']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>[/syntaxhighlighter]


It just kills off my entire page...I only see one section of the site.
Edited by HobbyMan on 13-12-2010 00:15,
0 replies
P
ps2cho
P
ps2cho 10
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
answered
Junior Member

Weird...google search doesn't really work too well with finding threads from this site I guess?

I didn't figure out what the issue was, but it seems it no longer gives me errors. I'll check back in a few hours and see if it is tracking yet

thread I found:
http://www.php-fusion.co.uk/forum/viewthread.php?thread_id=21381

I had same issue as Al_Capone on the 2nd to last post. I used the code posted by lelebart and the site now shows all parts and no errors. We'll see how it goes and i'll report back.
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

Glad to hear it. For future reference, please remember to use geshi tags when posting code.
0 replies
P
ps2cho
P
ps2cho 10
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
answered
Junior Member

Unfortunately no luck....Analytics shows a total of 4 views.....I consistently should be getting 200-300 unique every day. 600-800 pageviews.so it is not working.

Heres my full code:

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) 2002 - 2010 Nick Jones
| <a href="http://www.php-fusion.co.uk/" target="_blank" title="autolink">http://www.php-fu...</a>
+--------------------------------------------------------+
| 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 <a href="http://www.gnu.org/licenses/agpl.html." target="_blank" title="autolink">www.gnu.org/licen...</a> 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."wink;
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"wink);
if (typeof(_gat) == 'object'wink {
try {
var pageTracker = _gat._getTracker("UA-19233624-1"wink;
pageTracker._trackPageview();
} catch(err) {}
}
//]]>
</script>
EOD;
echo $google_analytics."\n";
?>
[/syntaxhighlighter]

..../includes/footer_include.php

Could have it have something to do with my theme not using this file?
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

Google Analytics does not have to go in footer it can go in header and it works exactly the same.

The easiest way without having to modify any files is to use the add_to_head function and place your code in a panel that does not use openside closeside.

This will do the trick.

Paste this in panels.

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
add_to_head("<script type='text/javascript'>

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>");[/syntaxhighlighter]
0 replies
P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

btw I've found your script, so your theme works fine.
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 8 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

C
C
Craig 14
  • Fusioneer, joined since
  • Contributed 4,462 posts on the community forums.
  • Started 212 threads in the forums
P
P
ps2cho 10
  • Junior Member, joined since
  • Contributed 22 posts on the community forums.
  • Started 11 threads in the forums
  • Started this discussions
H
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
P
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet