Finding out your View ID

In your Analytics account, select the Admin tab and select the required View.

In the View column click View Settings.

Configuring credentials in the Google Analytics Visualization module

You must configure the Google Analytics Visualization module to fetch data from the Google Analytics view. To do so, you load the credentials from the file saved to your computer when you created the service account. You then store the credentials in the module configuration.

Storing credentials in the Magnolia configuration

Name of the application requesting data from Google Analytics. For example: GAV.

servicePrivateKey

required if you want to store credentials in the Magnolia configuration.

See the screenshot of the open JSON file below.

serviceEmail

required if you want to store credentials in the Magnolia configuration.

See the screenshot of the open JSON file below.

Integrating with Pages app

Once integrated in the Pages app, Magnolia adds two new columns by default: Page views and Exit rateinfo.magnolia.ga.visualization.column.GoogleAnalyticsPageStatisticsColumnFormatter. You can configure the Pages app to display more data from Google Analytics.

The status bar extension info.magnolia.ga.visualization.extension.GoogleAnalyticsPageStatisticsExtension also displays some Google Analytics data by default and can be customized.

Configuring the Google Analytics Visualization column

info.magnolia.ga.visualization.column.GoogleAnalyticsPageStatisticsColumnDefinition extends info.magnolia.ui.workbench.column.definition.AbstractColumnDefinition. Only the properties specific to GoogleAnalyticsPageStatisticsColumnDefinition are described here. See the basic set of properties in the Column definition documentation.

Google Analytics Visualization app

The Google Analytics Visualization app uses Google Analytics Embed API to display more detailed statistics about pages in the form of charts. Every request to update a chart triggers a request to the Analytics API and provides real-time data from Google Analytics.

You can open the app in Tools > Page statistics or by clicking View page stats in the Pages app.

The app is configured under Configuration > /modules/google-analytics-visualization/apps/gav.

Chart view

You can use the chart view to define what type of data you want to display and how it should be displayed in the Google Analytics Visualization app.

Query string in Google Analytics URL

Google Analytics splits pages into multiple rows with different parameters. The Google Analytics Visualization module can only display (in columns, status bar extensions and in charts) data for URLs without parameters.

In the example above, the statistics for the Configuration/modules/google-analytics-visualization/config/credentialConfig/travel/contact.html page are split into 8 rows. You cannot get an accurate overview of the page statistics because they are not combined. The URLs must be merged into one row.

Merging URLs with different parameters

There are different ways of merging URLs. You can:

Use a canonical URL.

Exclude specific query parameters.

Use filters.

Google Analytics does not filter data retroactively.

Using a canonical URL

Add a <link> element with the attribute rel="canonical" to the <head> section of the pages. In our example with the /travel/contact.html page, add
<link rel="canonical" href="/travel/contact.html"/>.

Excluding specific query parameters

In Google Analytics you can exclude specific query parameters. However, this method cannot be used over several views; the parameters must be copied and pasted to every view. You must also know the query parameter names.

Add any query parameters that you do not want to see as a comma-separated list in the Exclude URL Query Parameters box.

If you do not want to merge URLs in your default view then you should have a separate view that strips query parameters.

Using filters

You can define filters instead of excluding specific query parameters. The advantage of using filters is that they can be defined on an account level and reused in multiple views. Whole query strings can be removed by using regular expressions, so you do not need to know the parameter names.

If you do not want to merge URLs in your default view then you should have a separate view that strips query parameters.

Select the Admin tab and navigate to Account/All Filters for account level filters or Account/View/Filters for view level filters.

Click Add Filter.

Under Filter Type, select Custom and Search and Replace.

In the Filter Field dropdown, select Request URI.

Add the following regular expression in the Search String field: \?.*

Click Save.

Path resolving

There are two implementations for path resolving of the info.magnolia.ga.visualization.pathresolver.GoogleAnalyticsPathResolver interface. The default value info.magnolia.ga.visualization.pathresolver.GoogleAnalyticsSimplePathResolver resolves the path from node path by adding or removing a prefix defined via prefixToRemove and prefixToAdd properties. If not defined, the node path is used.

The value can optionally be set to info.magnolia.ga.visualization.pathresolver.GoogleAnalyticsSiteAwarePathResolver if the path is to be resolved from site definition or URI2RepositoryMapping mechanism: