installing statcounter code/parse error

Started by ccheryld, September 24, 2014, 03:22:35 PM

Previous topic - Next topic

ccheryld

When I try to add the Statcounter Code into my template before the    </body></html>';
I get
The file you tried to save generated the following error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in index.template.php on line 344


How can I insert the code correctly?

The code is

<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=10046023;
var sc_invisible=1;
var sc_security="6d13d50c";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="site stats"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="http://c.statcounter.com/10046023/0/6d13d50c/1/"
alt="site stats"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->

Ninja ZX-10RR

Telling us which line is the 344 would be helpful ;)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

ccheryld

This is the beginning of line 331

function template_html_below()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo '

<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=10046023;
var sc_invisible=1;
var sc_security="6d13d50c";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure [nofollow]." : "http://www [nofollow].");
document.write("<sc"+"ript type='text/javascript' src='" +
scJsHost+
"statcounter.com/counter/counter.js'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="site stats"
href="http://statcounter.com/ [nofollow]" target="_blank"><img
class="statcounter"
src="http://c.statcounter.com/10046023/0/6d13d50c/1/ [nofollow]"
alt="site stats"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->

</body></html>';
}

Ninja ZX-10RR

Try this:
Code (find) Select

var sc_security="6d13d50c";


Code (replace) Select

var sc_security=6d13d50c;


Since the former code doesn't have the " I am just guessing since I am not a coder. ;)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

ccheryld


JBlaze

<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=10046023;
var sc_invisible=1;
var sc_security="6d13d50c";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type=\'text/javascript\' src='" +
scJsHost+
"statcounter.com/counter/counter.js\'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="site stats"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="http://c.statcounter.com/10046023/0/6d13d50c/1/"
alt="site stats"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->


Escaped all the apostrophes that were causing the parse error. PHP uses ' or " to signify the start and end of a string. In this case, since echo was followed by an apostrophe, that means any apostrophes that are not signifying the end of a string must be escaped using a backslash.
Jason Clemons
Former Team Member 2009 - 2012

Ninja ZX-10RR

I was on the right track with those apostrophes xD
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE


Ninja ZX-10RR

At least post which line :/ help us to help you :)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Burke ♞ Knight

I install the StatCounter code in all my sites, without editing the code.
Editing out the code, can cause more issues than you think, the way that statcounter's setup does.

Now, when got the code, which did you select?
I always select to get the default, as they add stuff to the codes for blogs, CMS's, etc.

JBlaze

<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=10046023;
var sc_invisible=1;
var sc_security="6d13d50c";
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type=\'text/javascript\' src=\'" +
scJsHost+
"statcounter.com/counter/counter.js\'></"+"script>");
</script>
<noscript><div class="statcounter"><a title="site stats"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="http://c.statcounter.com/10046023/0/6d13d50c/1/"
alt="site stats"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->


I missed one. Try it now.
Jason Clemons
Former Team Member 2009 - 2012

Burke ♞ Knight

Quote from: BurkeKnight on September 24, 2014, 06:32:15 PM
I install the StatCounter code in all my sites, without editing the code.
Editing out the code, can cause more issues than you think, the way that statcounter's setup does.

Now, when got the code, which did you select?
I always select to get the default, as they add stuff to the codes for blogs, CMS's, etc.

Please read this, as the default code is what works, and I have had it on well over 12 SMF forums.
Also, editing StatCounter's coding, can CAUSE count errors as well as connection issues with their servers, meaning that you more likely will not get the correct stats, making the whole thing basically useless.

Do note, StatCounter is already basically useless, as if anyone has an ad-blocker for their browser (more likely 95% of people) then it blocks StatCounter.

Ninja ZX-10RR

Quote from: BurkeKnight on September 24, 2014, 07:00:20 PM
Do note, StatCounter is already basically useless, as if anyone has an ad-blocker for their browser (more likely 95% of people) then it blocks StatCounter.
Seriously?  :o
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Burke ♞ Knight

Yep. I only see a few hits on any of my sites, when check the statcounter stats, yet, according to my server stats, as well as even Feedjit, that you all can see on my sites, I get a lot more.

Heck, even the live traffic stats, by Feedjit, gets blocked, 80% of the time.

ccheryld

I have an ad blocker...but thanks, Zilla...it worked this last time!!!!!
Thanks also to all who responded with help!

Ninja ZX-10RR

Quote from: BurkeKnight on September 24, 2014, 07:16:13 PM
Yep. I only see a few hits on any of my sites, when check the statcounter stats, yet, according to my server stats, as well as even Feedjit, that you all can see on my sites, I get a lot more.

Heck, even the live traffic stats, by Feedjit, gets blocked, 80% of the time.
Thanks for letting me know, in fact I was planning to put one but not anymore :P
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Advertisement: