Using Invisible Counter with Official StatCounter Plugin for WordPress

»»»Using Invisible Counter with Official StatCounter Plugin for WordPress

WordPress bloggers using StatCounter service to track and count visitors and page views statistics on their blogs can now download and install official WordPess plug-in for StatCounter to easily install StatCounter tracking code on self-hosted on the blog for comprehensive range of web analytic stats.

The StatCounter plugin provides easier way to install tracking code without the need to manually edit and modify the template files or code. However, it also introduces some inflexibility too, such as to make use of invisible counter. Although it’s possible to customize counter display style to invisible in “Configure Counter” option, but StatCounter sometimes add a StatCounter.com tagline to the web pages with code added even though the counter type is set to invisible in control panel.

To ensure that StatCounter always stay invisible when using Official StatCounter Plugin for WordPress to automatically display the tracking code on all WordPress blog posts and pages, a specific invisible tag code needed to be added into the tracking code by modifying the plug-in file.

Open StatCounter-Wordpress-Plugin.php in any text editor (if already uploaded to server, remote SSH into the server and change directory to \wp-content\plugins directory). Then go to the bottom of the code, and locate a block of text similar to the following text at around line 197:

	<!-- Start of StatCounter Code -->
	<script type="text/javascript">
	<!-- 
		var sc_project=<?php echo $sc_project; ?>; 
		var sc_partition=<?php echo $sc_part; ?>; 
		var sc_security="<?php echo $sc_security; ?>"; 
	//-->
	</script>
	<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
	<!-- End of StatCounter Code -->

Add an additional var line below to in between, or on top or bottom of existing 3 lines:

var sc_invisible=1; 

The final code will looks like below:

	<!-- Start of StatCounter Code -->
	<script type="text/javascript">
	<!-- 
		var sc_project=<?php echo $sc_project; ?>; 
		var sc_invisible=1; 
		var sc_partition=<?php echo $sc_part; ?>; 
		var sc_security="<?php echo $sc_security; ?>"; 
	//-->
	</script>
	<script type="text/javascript" src="http://www.statcounter.com/counter/counter_xhtml.js"></script>
	<!-- End of StatCounter Code -->

Upload the new plugin file to the server, or if you already editing on the server, save the file. Voila, the StatCounter will now always invisible to visitors’ eyes.

Update: Newer version of Official StatCounter plugin for WordPress has Force invisibility option that automatically makes the StatCounter invisible.

By | 2017-05-01T23:06:35+00:00 May 1st, 2017|Categories: Web Analytics|Tags: |2 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.

Connect with LK through Tech Journey on Facebook, Twitter or Google+.

  • Thanks a lot! This was helpful. I had the Statcounter plugin installed but really hadn't checked it, and then I noticed that the LINK was totally visible and it wasn't supposed to be. Your article totally helped me out! Thanks again.

  • Karim

    Don’t use that version, it got so many errors…

    This one better: https://wordpress.org/plugins/sc-littlebizzy/

Pin It on Pinterest

Share This

Share This

Share this post with your friends!