Path

ez.no / developer / articles / how to use ez publish extensions: google analytics


How to Use eZ Publish Extensions: Google Analytics

When using eZ Publish as a platform to build websites, organizations can make use of the Google Analytics service, an advanced website statistics application that provides detailed information about visitor activities.

Brookins Consulting has created an extension called BC Website Statistics, licensed under the GPL, that we are happy to share with the eZ Publish community. This tutorial is the second in the eZ Publish “How to” series. The first article ( How to Configure an eZ Publish Site) described basic setup of an “eZ Tennis Club” website. In this tutorial we will add the BC Website Statistics extension to the eZ Tennis Club site. You will also learn how to use the Google Analytics service and gain a general understanding of the eZ Publish extension system.

Definitions

  • Google Analytics (GA) - A free service offered by Google that generates detailed statistics about website visitors. One major advantage is that a webmaster can optimize his or her AdWords advertisement and marketing campaigns through the use of GA's analysis of where visitors came from, how long they stayed on the website and their geographical location.
  • Extension - A code component that “plugs in” to the eZ Publish core, providing custom application components and configurations.
  • Template operator – A mechanism that takes input, transforms it, and returns the result to the template. Template operators are programmed in PHP and are simple to create and plug in to the eZ Publish template system. eZ Publish has many built-in template operators.

Prerequisites

In order to get the most out of this tutorial:

  • Perform the steps described in the first article in this series, How to Configure an eZ Publish Site.
  • You must have access to the eZ Publish files on the file system.
  • You must have access to the eZ Publish Administration Interface.
  • Basic knowledge about the eZ Publish template language and / or PHP is useful, but not necessary.

Keep in mind that the interfaces, buttons, screenshots and procedures may vary from those found in this article if you use a version other than eZ Publish 3.9.2 and the Website Interface 1.2. In most cases these variations will be minor and we encourage you to always work with the latest stable version available.

Comments

Best practice n°2: If I remember correctly...

The extension has to call something on the onload... anyway, I personally find it easier to maintain to have everything in the head.

If you want to optimise the loading time:
1) use defer="defer" in the scripts (does defer the execution, not the loading if I'm right)

2) use a library that loads the script later once the dom is loaded. eg for jQuery:
$.getScript("http://www.google-analytics.com/urchin.js", function(){
_uacct="UA-xxxx-x";
urchinTracker();
});

Best practice 1: respect the standards

Hi,

For knut: do put a CDATA on you js code

<script type="text/javascript">
<![CDATA[
... big_brother.trackMe();
]]>
</script>

Placement of tracking code

Note: Best practice is to put the tracking code at the bottom of the page (right before </body>). If the analytics server you are tracking against are having a slowdown your page will be affected the higher up in the page you have it.

See: http://www.google.com/support/ana...bin/answer.py?hl=en&answer=26908

log in or create a user account to comment.

Article info

Writing for ez.no

Want to share your information? We publish your article on our Website.

Partner

Brookins Consulting helps organizations bring increased value to their eZ Publish solutions. Since 2001, Brookins Consulting offers eZ Publish solutions, development and support to customers in North America and worldwide. We help our customers solve uniquely complex problems with complete solutions.

Graham Brookins is a successful certified eZ Publish Developer and founder of Brookins Consulting, the leading eZ Partner in North America. Graham has a strong focus on request fulfillment, best practices and continuous improvement. He was nominated for two eZ awards in 2007. Graham saw the coming mass adoption of Free/Open Source Software solutions by both small and enterprise businesses. Graham offers value-added web application development and support, empowering local customers with web applications powered by eZ Publish. Graham enjoys supporting the eZ Publish community's continued education and growth. Web Application Development is his profession and passion; he also enjoys traveling, writing and free software. Graham asks 'Do you GNU? I do!'. Visit his personal website at grahambrookins.com.

License

This work is licensed under the GNU Free Documentation License (GFDL).

Download