Statcounter

Does anyone have any experience installing statcounter (statcounter.com) code in Omeka? If so, could you assist? I have tried, check the forums, and no progress.

I am using Omeka (most recent version) with Scripto on a Macbook Air.

Thanks, John

I think this is the first question we've gotten about that service.

I suspect that the pattern of what to do will be similar to the steps for Drupal or GoDaddy. Once you have the code from them, paste it into the commons/footer.php file for your theme.

Follow this guide to make a copy of the default footer.php file if there is not one in your theme.

I use Statcounter for getting statistics about visitors to my web sites.

For an Omeka-based site, I added a new project to my Statcounter account, registering the project URL to be the URL to the home page of the Omeka-based site.

I choose to use "Invisible Tracking" as the project option, instead of choosing to show a visible page counter or a Statcounter icon. The javascript that is generated will not have any code in it to show anything visible on the page.

If you want to show a visible page counter or provide a button to promote your use of Statcounter, choose one of the those options. In that case, the snippet of javascript you get will differ from the example shown below.

After adding the project, Statcounter asks you to choose an installation guide for your website. They have many choices in their list, such as Drupal, Flickr, Godaddy Website Tonight, Joomla, Typepad, WordPress. There is no choice for Omeka.

Choose the option on the far right, "Default Installation Guide".

When you click on that, a page appears holding a snippet of javascript that you can copy and paste into your footer.php file.

Statcounter will also email you the snippet of javascript so you have a long term record of what it is.

Instruction below the generated Statcounter Code at their website explain what to do with that code. It is aimed at someone who is using HTML files so it does not apply exactly to Omeka use.

As Patrick explained, customize a footer.php in your theme, following the instructions at the link he gave.

The customized version of footer.php needs to be changed to include the snippet of javascript that Statcounter gives you. Insert it just above the final body tag in footer.php.

Here is the snippet I was given, with my project identifier changed to "99999" and my security code changed to "X12345X", for publishing here. I do not change the values when using the snippet on my web site. Those are the values that Statcounter uses to know that reports it gets about a web page visitor will go into my project. The code you get from Statcounter will have your project identifier and security code.

<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=99999;
var sc_invisible=1;
var sc_security="X12345X";
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="web counter"
href="http://statcounter.com/" target="_blank"><img
class="statcounter"
src="http://c.statcounter.com/99999/0/X12345X/1/"
alt="web counter"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->

Here is how I edit that snippet before using it. I remove the noscript section that exists to do something when a visitor does not have javascript turned on.

By removing the noscript section I implement a policy of not doing anything to gather stats for visitors who visit the site with javascript turned off. Using the snippet exactly as Statcounter gives it to you is fine. It does something to get stats for when a visitor to the page does not have javascript turned on.

<!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=99999;
var sc_invisible=1;
var sc_security="X12345X";
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>
<!-- End of StatCounter Code for Default Guide -->

Here is the bottom of footer.php as it looks when I open it before making any changes to it. It is from the Berlin theme. Other themes are similar.

<script type="text/javascript">
    jQuery(document).ready(function(){
        Omeka.showAdvancedForm();
               Omeka.dropDown();
    });
</script>
</body>
</html>

I put the snippet of edited javascript from Statcounter just above the </body> tag. I choose to do it after the javascript code section that registers work for JQuery to do when the page loads. It could also go before that code section and all would work fine.

<script type="text/javascript">
    jQuery(document).ready(function(){
        Omeka.showAdvancedForm();
               Omeka.dropDown();
    });
</script>

<script type="text/javascript">
var sc_project=99999;
var sc_invisible=1;
var sc_security="X12345X";
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>

</body>
</html>

That's it.

Publish the changed footer.php file to your server. You should be able to view source on any page in the Omeka site and see the javascript snippet at the bottom of each page.

Back at Statcounter, when you look at reports within your account, you will start seeing reports about visitors to the site.

Statcounter does provide a button in your project account for doing a "Check Installation" from their web site. It verifies that the snippet of javascript is working properly at your web site. Use the Check Installation button after publishing the changed footer.php file if you want to get a positive confirmation from Statcounter that the code is working. Seeing stats in your project indicates success just as well.

The same steps are done to customize a footer.php file if you use Google Analytics instead of StatCounter for gathering reports about web site visitors. Both services provide a snippet of javascript to put into the footer of every page, just above the the close body tag.

Bob,

Great work! Thanks for writing up this guide!