Google Analytics [message #163150] |
Sun, 03 October 2010 00:31  |
Volvospeed
 Messages: 17 Registered: September 2010
Karma: 0
|
Junior Member |
add to buddy list ignore all messages by this user
|
|
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 #163157 is a reply to message #163150] |
Sun, 03 October 2010 10:57   |
Ernesto
 Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
add to buddy list ignore all messages by this user
|
|
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 #163161 is a reply to message #163160] |
Sun, 03 October 2010 11:29   |
Ernesto
 Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
add to buddy list ignore all messages by this user
|
|
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 11:31   |
Ernesto
 Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
add to buddy list ignore all messages by this user
|
|
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 04:36   |
Ernesto
 Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
add to buddy list ignore all messages by this user
|
|
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 04:36] Report message to a moderator
|
|
|
|
|
Re: Google Analytics [message #163170 is a reply to message #163169] |
Mon, 04 October 2010 13:12   |
Ernesto
 Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
add to buddy list ignore all messages by this user
|
|
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 13:26] Report message to a moderator
|
|
|
|
|
|
|
|
|
|