Home / Blog / Installing Google Analytics

Installing Google Analytics

Google Analytics is the big dog when it comes to tracking site visitors. Installing it in eZ Publish is quite a simple task.

After signing up with Google Analytics, we were given some simple JavaScript code to place on every page we want to be tracked. In eZ Publish, the pagelayout template represents the basic layout of all pages in a given siteaccess. Therefore, all we had to do was place the code at the bottom of that template and it will be loaded on all site pages! Now we can access useful information such as who is visiting our site, how they got here (did they directly type our address? did they come here from another link? did they use a search engine and if so, what keywords did they use?), which pages they viewed, and more.

On ezsystems.ca, because we use the Website Interface, the pagelayout template is found at extension/ezwebin/design/ezwebin/templates/pagelayout.tpl. After we added the code, we cleared the eZ Publish cache (using the Clear cache window on the right of the Administration Interface). That's all!

So that all of us at the eZ Systems North America office can access the statistics, we used the Google Analytics Access Manager. The link to the Access Manager is found at the bottom of the welcome page after you log into Google Analytics. There, I added the Google accounts of my co-workers (the screenshot shows only me, but everybody else is there now):

Google Analytics Access Manager

Google Analytics Access Manager

Need more advanced Google Analytics management for your eZ Publish site, especially if you have a webshop? Check out Graham Brookins' Google Analytics extension.

Comments

Adding GA to each page so that your clients can update it.

Add a TextBox class to the [Template Look].
Initialize it at the top of your page_layout.tpl.
Call it at the footer of the page_layout.tpl:
<pre>
{if $pagedesign}
{$pagedesign.data_map.footer_script.content}
{/if}
</pre>

An object containing Google Analytics code?

Hi Benjamin,

Thanks for the tip -- can you provide a bit more context as to what this entails? Do you mean to create an object that would hold only the Google Analytics code, so that it could be edited in the Administration Interface (or Website Interface)?

Comments are closed