Show last authors
1 This extension allows to integrate Google Analytics Reports into XWiki, by providing a set of Macro to use in XWiki either on your Dashboard or on any page.
2
3 This extension is using the [[Google Analytics Embed API>>https://developers.google.com/analytics/devguides/reporting/embed/v1/]]. The documentation on the Google web site can help to make more complex graphs as the ones available by default.
4
5 {{toc start="2"/}}
6
7 == How to install ==
8
9 To install you need to setup authentication with Google Analytics. To do this two methods are possible which are described below.
10
11 === Authenticate using Client ID ===
12
13 This method will allow users to authenticate on their Google Account and access the reports for which they have rights on Google Analytics.
14 This method will not allow to show Google Analytics reports to non-authorized users.
15
16 Step 1/ Create a project and a client ID according to [[this Tutorial>>https://developers.google.com/api-client-library/javascript/start/start-js#Setup]].
17 Step 2/ Make sure to not forget to set the "Authorized Javascript Origin" to the URL of your web server.
18 Step 3/ Make sure to add the Google Analytics API to the APIs available for your project (still in the developer console)
19 Step 4/ Finally add the client ID to your [[Google Analytics Embed API Configuration>>XWiki.XWikiPreferences||queryString="editor=globaladmin&section=Google+Analytics+Embed+API"]]
20
21 === Authenticate using a Service Account ===
22
23 This method will allow to authenticate on the server side and will not require users to log-in on their user account.
24 This method allows to show Google Analytics reports to any users. Users that can edit in the wiki will allow to access most of the Google Analytics data authorized to the Service Account.
25
26 Setting-up server authentication is explain on the [[Google Analytics Embed API web site>>https://ga-dev-tools.appspot.com/embed-api/server-side-authorization/]] and has a few steps:
27
28 Step 1/ Create a project and a service account according to [[this Tutorial>>https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount]].
29 Step 2/ Make sure to add the Google Analytics API to the APIs available for your project (still in the developer console)
30 Step 3/ Once created, download the "p12" file and save it to your server in /WEB-INF/GoogleAnalytics.p12 of your XWiki installation
31 (usually in webapps/xwiki/WEB-INF/. If you don't have access to the server, ask your Hosting Administrator.)
32 Step 4/ Add the service account with read rights to your Google Analytics Account
33 Step 5/ Finally add the service account to your [[Google Analytics Embed API Configuration>>XWiki.XWikiPreferences||queryString="editor=globaladmin&section=Google+Analytics+Embed+API"]]
34
35 == Check the Demos ==
36
37 Verify your configration by accessing the [[Demo page>>Demo]]. This will also allow you to see the ID of your Google Analytics report which you can use in the macros in the next section.
38
39 == Use the Macros ==
40
41 The following macros are available:
42
43 === gachart ===
44
45 This macro allows to add a chart of your Google Analytics data. This is a most common macro to use to make customized reports.
46
47 {{code}}
48 {{gachart /}}
49 {{/code}}
50
51 |= Parameter |= Default value |= Description
52 | clientid | The macro will use the client ID set in the Google Analytics Embed API Preferences of the local wiki, or if not present, of the main wiki. | Client ID used for Authentication
53 | serviceaccount | The macro will use the service account set in the Google Analytics Embed API Preferences of the local wiki, or if not present, of the main wiki. | Service Account used for Authentication if client ID is not set
54 | ids | None | ID of the Google Analytics tracked web site (ga:XXXXXXX). You can find out these values using the [[Demo]] page
55 | metrics | ga:sessions | One or more metric to display
56 | dimensions | ga:date | Field to use to break down the data
57 | sort | | Sorting field (this does not always make sense)
58 | start-date | 30DaysAgo | Start date of the period reported on
59 | end-date | yesterday | End date of the period reported on
60 | max-results | 6 | Maximum results to display (the remaining results are reported as "Other")
61 | type | LINE | Type of report (LINE, COLUMN, BAR, TABLE, and GEO)
62 | width | 100% | Width of the report
63
64 === googleanalytics ===
65
66 This macro allows to add you custom Google Analytics Embed API code to display any report. This macro requires developer skills.
67
68 {{code}}
69 {{googleanalytics}}
70 .. js code ..
71 {{/googleanalytics}}
72 {{/code}}
73
74 |= Parameter |= Default value |= Description
75 | clientid | The macro will use the client ID set in the Google Analytics Embed API Preferences of the local wiki, or if not present, of the main wiki. | Client ID used for Authentication
76 | serviceaccount | The macro will use the service account set in the Google Analytics Embed API Preferences of the local wiki, or if not present, of the main wiki. | Service Account used for Authentication if client ID is not set
77 | content field | | The content field of the macro should be Javascript code written to the Embed API