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 -->
Telling us which line is the 344 would be helpful ;)
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>';
}
Try this:
var sc_security="6d13d50c";
var sc_security=6d13d50c;
Since the former code doesn't have the " I am just guessing since I am not a coder. ;)
thanks,but didn't take..same error.
<!-- 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.
I was on the right track with those apostrophes xD
same error
At least post which line :/ help us to help you :)
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.
<!-- 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.
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.
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
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.
I have an ad blocker...but thanks, Zilla...it worked this last time!!!!!
Thanks also to all who responded with help!
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