eZ Community » Learn » eZ Publish » How to Use eZ Publish Extensions:...

How to Use eZ Publish Extensions: Google Analytics

Monday 29 October 2007 11:00:00 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Installing the template operator

The BC Website Statistics extension primarily consists of a template operator for the standard design. It could be considered a template operator extension.

If you are using a custom design extension (other than the Website Interface extension), you should create a pagelayout.tpl template override. Template overrides (see the documentation) and creating extensions (see the eZ Publish Basics book) are beyond the scope of this article. Therefore, in this article we will modify the pagelayout.tpl template for the Website Interface extension for the eZ Tennis Club site. However, on a real installation, you should do this through a template override because this file gets overwritten when you upgrade the Website Interface.

Place the template operator code {'false'|bc_ga_urchin()} as the last code element before the </head> tag in the extension/ezwebin/design/ezwebin/templates/pagelayout.tpl file.

{foreach ezini( 'JavaScriptSettings', 'JavaScriptList', 'design.ini' ) as $script} 

   <script language="javascript" type="text/javascript" src={concat( 'javascript/', $script )|ezdesign}></script>
{/foreach}

{* The following is the required bcwebsitestatistics template operator *}
{'false'|bc_ga_urchin()} 
</head>
<body> 


<!-- Complete page area: START -->

Testing the extension

To test that the BC Website Statistics extension has been correctly installed and configured:

  1. Clear the INI and template caches. In the Administration Interface, expand the Clear cache window if necessary, select Ini settings from the drop-down menu, then click the Clear button. Repeat this step twice but select Template and Static from the drop-down menu. As clearing all of the caches is resource-intensive, we do not want to clear all of the caches unless it is absolutely necessary, especially on large, busy sites.
  2. Log in to the Google Analytics website and confirm the correct installation of the template code by clicking the Edit link for your site under the Settings column. Then, click the Check status link.

Testing the page statistics

Browse your site, loading several pages in order to generate activity that will be reported by Google Analytics. You will have to wait up to 24 hours after your first round of testing for the service to store and display the statistics in your reports.

Debugging

If no statistics are reported by Google Analytics, the first thing to check is that you cleared the cache after installing the extension and template operator into the design template.

Then, check whether your template override for the pagelayout.tpl file is being recognized by the system. While viewing your site in a browser, right-click on an empty spot and select “View Page Source” (or the menu item specific to your browser). Then, look for this code:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">

If that code is not present, enable template debugging by adding the following settings to the settings/override/site.ini.append.php file then clear the Ini settings and Static caches.

[DebugSettings]
DebugOutput=enabled

[TemplateSettings]
Debug=enabled
ShowUsedTemplates=enabled 
ShowXHTMLCode=disabled

Upon enabling the debug output, you will see a list of used templates, source code comments containing the path of templates used and general debug warnings, notices and errors. This information can be used to determine the cause of problems.

36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)

Proudly Developed with from