|
| 1 | +// Google Analytics is a contentious issue inside Read the Docs and in our community. |
| 2 | +// Some users are very sensitive and privacy conscious to usage of GA. |
| 3 | +// Other users want their own GA tracker on their docs to see the usage their docs get. |
| 4 | +// The developers at Read the Docs understand that different users have different priorities |
| 5 | +// and we try to respect the different viewpoints as much as possible while also accomplishing |
| 6 | +// our own goals. |
| 7 | + |
| 8 | +// Read the Docs largely funds our operations and development through advertising and |
| 9 | +// advertisers ask us questions that are easily answered with an analytics solution like |
| 10 | +// "how many users do you have in Switzerland browsing Python docs?". We need to be able |
| 11 | +// to easily get this data. We also use data from GA for some development decisions such |
| 12 | +// as what browsers to support (or not) or how much usage a particular page/feature gets. |
| 13 | + |
| 14 | +// We have taken steps with GA to address some of the privacy issues. |
| 15 | +// Read the Docs instructs Google to anonymize IPs sent to them before they are stored (see below). |
| 16 | + |
| 17 | +// We are always exploring our options with respect to analytics and if you would like |
| 18 | +// to discuss further, feel free to open an issue on github. |
| 19 | + |
| 20 | + |
| 21 | +// RTD Analytics Code |
| 22 | + |
| 23 | +(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| 24 | +(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| 25 | +m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| 26 | +})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
| 27 | + |
| 28 | +if (typeof READTHEDOCS_DATA !== 'undefined') { |
| 29 | + if (READTHEDOCS_DATA.global_analytics_code) { |
| 30 | + ga('create', READTHEDOCS_DATA.global_analytics_code, 'auto', 'rtfd'); |
| 31 | + ga('rtfd.set', 'dimension1', READTHEDOCS_DATA.project); |
| 32 | + ga('rtfd.set', 'dimension2', READTHEDOCS_DATA.version); |
| 33 | + ga('rtfd.set', 'dimension3', READTHEDOCS_DATA.language); |
| 34 | + ga('rtfd.set', 'dimension4', READTHEDOCS_DATA.theme); |
| 35 | + ga('rtfd.set', 'dimension5', READTHEDOCS_DATA.programming_language); |
| 36 | + ga('rtfd.set', 'dimension6', READTHEDOCS_DATA.builder); |
| 37 | + ga('rtfd.set', 'anonymizeIp', true); |
| 38 | + ga('rtfd.send', 'pageview'); |
| 39 | + } |
| 40 | + |
| 41 | + // User Analytics Code |
| 42 | + if (READTHEDOCS_DATA.user_analytics_code) { |
| 43 | + ga('create', READTHEDOCS_DATA.user_analytics_code, 'auto', 'user'); |
| 44 | + ga('user.set', 'anonymizeIp', true); |
| 45 | + ga('user.send', 'pageview'); |
| 46 | + } |
| 47 | + // End User Analytics Code |
| 48 | +} |
| 49 | + |
| 50 | +// end RTD Analytics Code |
0 commit comments