Magnolia 4.5 reached end of life on June 30, 2016. This branch is no longer supported, see End-of-life policy.
The Google Analytics module integrates Magnolia websites with Google Analytics. The module is based on the gaTracker jQuery plugin designed by Jason Huck and enhanced by David Simpson. The module is fully configurable within Magnolia and no additional coding is necessary. Google Analytics is a powerful solution for analyzing website traffic and how users interact on your site. It is possible to monitor virtually all site activity, even on individual elements of a page.
The module is fully integrated with the Standard Templating Kit.
Google Analytics for STK is a community module. It is included in the Enterprise Edition bundle and typically already installed. Go to Magnolia Store > Installed modules in AdminCentral to check. It is not included in the Community Edition bundle. Community Edition users need to download and install it individually. To install the module, see the general module installation instructions.
See the general module uninstalling instructions and advice.
The Google Analytics module configuration requires a unique GA tracking code (UA-XXXXXXXX-X) that you will find in your GA account.
The module is configured in
Community Edition users are limited to a single site and should configure GA in the
To start GA tracking, set the
enabled property to
true and enter your GA tracking code for the
The configurable properties within the
/default/tracking node are dealt with below in Tracking options. If no specific tracking configurations are added, the
/default configuration essentially tracks pageviews, but GA does provide a lot of detail about user behavior and sources.
init-gatracker. You can view these in Templating Kit > Resources
These scripts, in conjunction with the GoogleAnalyticsModule class and GoogleAnalyticsJSResourceModel model class define and implement the GA requirements. They insert the required parameters into the HTML code on each page:
GoogleAnalyticsJSResourceModeltranslates the Magnolia configuration to a JavaBean using the Node2Bean mechanism.
init-gatrackerrequests the tracking configuration from the model and injects the values into the GA configuration.
GA is flexible and can be customized to track almost anything. For more information see Google Analytics Developer Guides. The Magnolia module allows for most options and additional customizations can be made.
There are four tracking configuration options in
/modules/google-analytics/config/sites/default/tracking that allow for the configuration of detailed tracking of
class supports the configuration options and properties.
The Google Analytics module uses virtual pageviews to track download, external, mailto and anchor links. GA does not track links by default unless they are specifically tagged. The
_trackPageview() method is used to tag the links and the results appear in GA as virtual pages. The only drawback of this method is that the clicks are added to the total pageview count.
Links are configured in
/modules/google-analytics/config/sites/default/tracking/links. There are four subnodes:
/anchor and each has two configurable properties:
To enable and disable the tag
The prefix added to the link that appears in the GA reports
links/download/extensions node allows for the definition of the file extensions to be included. Each extension is registered in an individual node and there are two configurable properties:
To enable and disable the extension
The node name
To view the links statistics in the GA interface go to Behavior > Site Content and filter on the terms “downloads”, “external”,”mailtos” or “anchors”.
Here are a few results for
anchor links in the demoauthor GA account.
Event Tracking allows you to record user interaction with website elements. This is accomplished by attaching the method call to the particular UI element. The accessed page element is identified in GA with a path that starts with
/events-tracking. With events tracking you can, for example, determine the number of times a form was submitted, the effectiveness of a particular component type or the popularity of a page within a grouped teaser.
class defines a search pattern for tracking events as a
submit. Within these categories of events, any number of patterns can be configured. Each pattern corresponds to a CSS element defined in
styles.ccs that is available in Templating Kit > Resources >
/templating-kit/themes/pop/css. Tracking is triggered when GA encounters the CSS element in the HTML code of the page.
The nodes configured under
/submit/patterns allow for tracking activity on specific page elements. Each configuration node has four properties.
Defines the CSS element that triggers event tracking
Defines whether the pattern should be used
Defines whether the
Defines the link submitted to GA when tracking is triggered. It does not form part of the rendered HTML. In GA, it represents a tracked event in the statistics
The pattern set in the
statsLink property is the page path you see in the GA reports. For example, the
/tw-paging-stage node in the screenshot above is configured to record statistics for the
stkStagePaging component on the home pages of the demo sites. The pattern defines a readable path and its constituent parts translate as follows:
An event is tracked
It is a a click event
It is a teaser element
|The element resides in the |
|The specific action clicked|
In GA go to Behavior > Site Content and filter on "events-tracking" to see the results. Pageview calculations are unaffected by user activity tracked using this method.
Here are a few
events results for the demoauthor GA account.
By default, GA tracks content for a single domain, such as
www.example.com. Cross-domain tracking facilitates tracking of subdomains and across separate domains within a single GA account. It is useful in many instances, for example to track users referred to a third-party payment gateway or a subdomain hosting a blog. This function should not be confused with Mapping to multiple domains above.
jquery-gatracker.js, available in STK > Resources in
/templating-kit/js/ga, uses three methods for cross-domain tracking:
Sets the top-level domain name for cookies
Sets the linker functionality flag as part of enabling cross-domain user tracking
Passes the cookies from the referring form to another site in a string appended to the action value of the form (HTTP POST)
Cross-domain tracking is configured in
/modules/google-analytics/sites/default/tracking/domain. There are three configurable properties:
URL of third-party site
Top-level domain to track
To enable and disable cross-domain tracking
Additional miscellaneous tracking options can be configured in
/modules/google-analytics/config/site/default/tracking/misc. There are two general properties:
To enable and disable pageview tracking for
Enables client-side visitor sampling. This feature is designed for high-traffic sites to reduce the load on all systems. Only a percentage of page views are tracked
The organic search feature allows you to add to the list of organic search engines recognized by GA. This is helpful, for example to add local search engines that GA does not recognize. You can find a list of engines that GA tracks by default at Search Engine Configuration.
Organic search engines are configured in >
class defines the search pattern for tracking organic search engines.
For each search engine there are three configurable properties.
Defines whether the pattern should be used
Defines the query parameter name of the search engine URL, for examples 'q' in URL '
Defines the URL of the search engine to track
The Extended Templating Kit module available to Enterprise Edition users supports multiple domains. These are configured in Templating Kit > Site Definitions. Here are the site definitions for the demo sites.
Multiple domains can be tracked in a single GA account or different accounts can be used for each. The extends feature allows you to use the
/default GA configuration for multiple sites and domains by defining only the properties that are different in the new configuration.
The configuration below includes all the demo sites in a single GA account, by extending the
/demo-project configurations. Note that node names of the sites configured in Templating Kit > Site Definitions must match the node names in the GA configuration identically.
Here are the results in the
/demo-features sites in a single account.
The configuration below applies all the configurations of
/default to the
/demo-features site, but it is tracked in a different GA account.