Adding Google analytics to your website is fairly easy. You need a google analytics account, some javascript, add that to your website html, et voila, you can track your visitors.
Off course, someone needs to analyse this data, see how many visitors your site gets, see where they come from, …
Google provides a website where you can see all this, but it might not always be easy for users to work with that tool.
This Alchemy plugin allows you to see Google analytics data for your website, right from your Tridion CM GUI. It adds a Google Analytics dashboard in the publication dialog.
To get this working, you need to perform the following tasks
- Install the plugin from the Alchemy webstore
- Create a new Google API key (for this, you need a google account).
- Go to https://console.developers.google.com/, log in with your google account, and create a new project
- In the project, open the API page, find the Analytics API and enable it.
- Once it’s enabled, you should see a usage report for this API. As it’s only just created, you won’t see much here
- Next, open the credentials window. Here, you need to create a new service credential, to let Tridion access your Analytics API account. To do this, click the ‘Create new client ID’ button. In the popup, choose a ‘service account’.
- When it’s created, you should see a new service account Client ID, email address etc.
You will need the Email address and you should also click the ‘Generate new P12 key’ button. This will download a file to your local machine. - Now, open your google analytics dashboard, and add a new user. Here, you should add the email address you received with your new service account. The account only needs read rights.
- With this data, go back to your Tridion machine.
Create a new metadata schema with the following fields (you can also add these fields to an existing metadata schema). The metadata schema should be applied to a publication.- gaServiceAccount (text field)
- keyPath (text field)
- gaProfile (text field)
- Now, open a publication, and apply this metadata schema to it. You have to fill in the fields as follows :
- The service account field should contain the e-mail address you got earlier.
- The keyPath field should point to the p12 file you downloaded earlier. This file should be copied on your Tridion server. The field should contain the full path (c:\my-key-folder\my-service-key-file.p12).
- The gaProfile should contain your google analytics profile ID. You can get this by logging in to the google analytics site (where you added that service account email earlier), and get the profile ID from the url.
The number after the p in the url is your profile ID - Once you have this set up, save and close your publication, and reopen it.
When your alchemy plugin is active, you should see a new tab in your publication dialog “Google Analyticsâ€, and when opening it, you should see a number of graphs for your website usage
Tips :
If you have multiple publications for different websites, you could configure each publication separately to show analytics for one specific website.
Future improvements
Currently, the dashboard is only showing a couple of graphs. A next version should allow you to configure this dashboard, so you can select which data you want to show in the page.