Google Analytics [message #163150] |
Sun, 03 October 2010 04:31 |
Volvospeed
Messages: 17 Registered: September 2010
Karma: 0
|
Junior Member |
|
|
I just tried inserting my analytics code in the footer file and got the following error after rebuilding the theme:
T_CONSTANT_ENCAPSED_STRING on line 492
Line 492 of the index.php file is:
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
Everything looks ok to me. I tried breaking out the code but had the same issue. Anyone else seen this before I spend to much time looking into it?
|
|
|
|
Re: Google Analytics [message #163152 is a reply to message #163151] |
Sun, 03 October 2010 08:56 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
You have to backslash the thingimabobs
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
has to be
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
Ginnunga Gaming
|
|
|
|
Re: Google Analytics [message #163157 is a reply to message #163150] |
Sun, 03 October 2010 14:57 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
var s = document.getElementsByTagName('\script\')[0]; s.parentNode.insertBefore(ga, s);
is not correct
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
is correct (apostrophe on the wrong place)
You have to backslash all the apostrophes if you place them in footer.
Like this
</script>
<div style="text-align: center;">
<script type="text/javascript"><!--
google_ad_client = "pub-89928376906811";
/* 728x90, created 9/23/10 */
google_ad_slot = "1253056536";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br>
<br>
</b><b>.::</b> Didn't Find What You Are Looking For? Visit Our Parent
Site <a href="http://volvospeed.com/vs_forum/">Volvospeed</a> <b>::.</b>
<b><br>.::</b> <a href="mailto:webmaster(at)volvospeed(dot)com">Contact</a> <b>::</b>
<a href="index.php?t=index&">Home</a> <b>::.<br>
</td></tr></table>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push([\'_setAccount\', \'UA-315562-4\']);
_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\') + <?php echo google-analytics.com/ga.js\';
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Ginnunga Gaming
|
|
|
|
Re: Google Analytics [message #163159 is a reply to message #163158] |
Sun, 03 October 2010 15:00 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
Why you get the problem is because when the forum compiles the theme, it will interpret the apostrophes as endings of a PHP argument/string, whatever, so to ensure that the forum does not execute them in PHP mode, you tell PHP that they are just symbols and nothing the engine needs to interpret. You do this by backslashing them.
Ginnunga Gaming
|
|
|
|
Re: Google Analytics [message #163161 is a reply to message #163160] |
Sun, 03 October 2010 15:29 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
Alright, it wasn't the apostrophes, you can actually use them in the footer - its the <?php thing that messes you up
Maybe this works?
</script>
<div style="text-align: center;">
<script type="text/javascript">
<!--
google_ad_client = "pub-89928376906811";
google_ad_slot = "1253056536";
google_ad_width = "728";
google_ad_height = "90";
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br>
<br>
</b><b>.::</b> Didn't Find What You Are Looking For? Visit Our Parent
Site <a href="http://volvospeed.com/vs_forum/">Volvospeed</a> <b>::.</b>
<b><br>.::</b> <a href="mailto:webmaster(at)volvospeed(dot)com">Contact</a> <b>::</b>
<a href="index.php?t=index&">Home</a> <b>::.<br>
</td></tr></table>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push([\'_setAccount\', \'UA-315562-4\']);
_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>
Ginnunga Gaming
|
|
|
Re: Google Analytics [message #163162 is a reply to message #163161] |
Sun, 03 October 2010 15:31 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
I also think google updated their tracking code, this is what i found at a quick quick glance:
<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">
try {
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
</script>
Ginnunga Gaming
|
|
|
|
|
Re: Google Analytics [message #163165 is a reply to message #163164] |
Mon, 04 October 2010 08:36 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
Yes, my fault, I messed up a quote
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push([\'_setAccount\', \'UA-315562-4\']);
_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>
should work
Ginnunga Gaming
[Updated on: Mon, 04 October 2010 08:36] Report message to a moderator
|
|
|
|
|
Re: Google Analytics [message #163170 is a reply to message #163169] |
Mon, 04 October 2010 17:12 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
Just use the damn quote likes naudefj has on this form hehe. I use very old analytics code, so couldn't copy mine.
Edit: I have strong hate for apostrophes, they always cause me trouble, I am such a noob =(
<script type="text/javascript">
// Google analytics.
var _gaq = _gaq || [];
_gaq.push(["_setAccount", "UA-315562-4"]);
_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>
Ginnunga Gaming
[Updated on: Mon, 04 October 2010 17:26] Report message to a moderator
|
|
|
|
|
|
|
|
|
|