1====== Google Analytics for DokuWiki ======
2
3===== About =====
4
5This tool allows you to set a code for use with [[https://en.wikipedia.org/wiki/Google_Analytics|Google Analytics]], which allows you to track your visitors.
6
7===== Setup =====
8
9This plugin generates JavaScript code that is automatically included into your site via the ''lib/exe/js.php'' file. (Which you can inspect via your browser's "developer tools.")
10
11Set the options for this plugin via the **Configuration Settings** menu from the DokuWiki admin menu. (It will be near the bottom of the page.)
12
13You may use one of two tracking options:
14
15  * **Basic** "Google Analytics ID" (also known as "[[https://developers.google.com/analytics/devguides/collection/analyticsjs|analytics.js]]") using a **UA-XXXXXX-XX** code
16  * **Newer** "Global Site Tag ID" (also known as "[[https://developers.google.com/analytics/devguides/collection/gtagjs|gtag.js]]") using a **G-XXXXXXXXXX** code
17
18If you set a "Global Site Tag ID", then this method will be used and any "Google Analytics ID" / **UA-XXXXXXX-XX** specific settings will be ignored.
19
20===== Advanced Usage =====
21
22To use the advanced "tagging" features of ''analytics.js'' or ''gtag.js'', you will need to be able to embed JavaScript within your DokuWiki pages. You can accomplish this in one of three ways:
23
24  * [[:wiki:syntax#embedding_html_and_php|Enabling embedded HTML]] in your local DokuWiki instance (Look for ''htmlok'' in Configuration Settings)
25  * Allow embedded JavaScript via a plugin like the [[doku>plugin:inlinejs|InlineJS Plugin]]
26  * Edit your site's template to add "tagging" directly
27
28Allowing embedded HTML / JavaScript will give you the most flexibility for per-page tagging, but it can open your site to [[https://en.wikipedia.org/wiki/Cross-site_scripting|Cross-site Scripting]] attacks if you're not careful. If you lock down who can edit your wiki pages and trust your users, you should be fine though.
29
30If you edit your template (the third option), make sure to make notes of what you change, as "upgrading" your template will revert any changes you've made.
31
32===== Support =====
33
34For further support or discussion, please see the official plugin page [[doku>plugin:googleanalytics|here]].
35
36If you find this plugin useful, please consider supporting the project via [[http://tjgrant.com/wiki/donate|Donations]] or [[https://github.com/sponsors/tatewake|Sponsorships]]; thank you!
37