Advertisement:

Author Topic: installing statcounter code/parse error  (Read 5999 times)

Offline ccheryld

  • Semi-Newbie
  • *
  • Posts: 36
installing statcounter code/parse error
« on: September 24, 2014, 03:22:35 PM »
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 -->

Offline Ninja ZX-10RR

  • SMF Hero
  • ******
  • Posts: 2,150
  • Gender: Male
  • Sniper Legends
    • Flavio93Zena on Facebook
    • Virtual Interactive Games Entertainment Forum
Re: installing statcounter code/parse error
« Reply #1 on: September 24, 2014, 03:28:09 PM »
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

Offline ccheryld

  • Semi-Newbie
  • *
  • Posts: 36
Re: installing statcounter code/parse error
« Reply #2 on: September 24, 2014, 03:47:32 PM »
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>';
}

Offline Ninja ZX-10RR

  • SMF Hero
  • ******
  • Posts: 2,150
  • Gender: Male
  • Sniper Legends
    • Flavio93Zena on Facebook
    • Virtual Interactive Games Entertainment Forum
Re: installing statcounter code/parse error
« Reply #3 on: September 24, 2014, 04:41:54 PM »
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

Offline ccheryld

  • Semi-Newbie
  • *
  • Posts: 36
Re: installing statcounter code/parse error
« Reply #4 on: September 24, 2014, 05:10:29 PM »
thanks,but didn't take..same error.

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: installing statcounter code/parse error
« Reply #5 on: September 24, 2014, 05:31:22 PM »
Code: [Select]
<!-- 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 Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline Ninja ZX-10RR

  • SMF Hero
  • ******
  • Posts: 2,150
  • Gender: Male
  • Sniper Legends
    • Flavio93Zena on Facebook
    • Virtual Interactive Games Entertainment Forum
Re: installing statcounter code/parse error
« Reply #6 on: September 24, 2014, 05:33:39 PM »
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

Offline ccheryld

  • Semi-Newbie
  • *
  • Posts: 36
Re: installing statcounter code/parse error
« Reply #7 on: September 24, 2014, 06:01:04 PM »
same error

Offline Ninja ZX-10RR

  • SMF Hero
  • ******
  • Posts: 2,150
  • Gender: Male
  • Sniper Legends
    • Flavio93Zena on Facebook
    • Virtual Interactive Games Entertainment Forum
Re: installing statcounter code/parse error
« Reply #8 on: September 24, 2014, 06:29:18 PM »
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

Offline Burke ♞ Knight

  • SMF Hero
  • ******
  • Posts: 3,534
Re: installing statcounter code/parse error
« Reply #9 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.

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: installing statcounter code/parse error
« Reply #10 on: September 24, 2014, 06:35:09 PM »
Code: [Select]
<!-- 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 Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline Burke ♞ Knight

  • SMF Hero
  • ******
  • Posts: 3,534
Re: installing statcounter code/parse error
« Reply #11 on: September 24, 2014, 07:00:20 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.

Offline Ninja ZX-10RR

  • SMF Hero
  • ******
  • Posts: 2,150
  • Gender: Male
  • Sniper Legends
    • Flavio93Zena on Facebook
    • Virtual Interactive Games Entertainment Forum
Re: installing statcounter code/parse error
« Reply #12 on: September 24, 2014, 07:10:33 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

Offline Burke ♞ Knight

  • SMF Hero
  • ******
  • Posts: 3,534
Re: installing statcounter code/parse error
« Reply #13 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.

Offline ccheryld

  • Semi-Newbie
  • *
  • Posts: 36
Re: installing statcounter code/parse error
« Reply #14 on: September 24, 2014, 07:16:22 PM »
I have an ad blocker...but thanks, Zilla...it worked this last time!!!!!
Thanks also to all who responded with help!

Offline Ninja ZX-10RR

  • SMF Hero
  • ******
  • Posts: 2,150
  • Gender: Male
  • Sniper Legends
    • Flavio93Zena on Facebook
    • Virtual Interactive Games Entertainment Forum
Re: installing statcounter code/parse error
« Reply #15 on: September 24, 2014, 07:17:45 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