mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-21 04:57:05 +02:00
feat(v2): support IP anonymization for Google Analytics plugin (#2148)
* Support IP anonymization for google analytics * Fixes * Add docs * typo fix * Fix syntax * document in suggested place * attempted to add functionality to gtag plugin * Remove from api-site-config * document in appropriate places * fix anonymize IP Co-authored-by: Yangshun Tay <tay.yang.shun@gmail.com>
This commit is contained in:
parent
5e821fd4e0
commit
ad031a15a4
3 changed files with 10 additions and 3 deletions
|
@ -18,7 +18,7 @@ module.exports = function(context) {
|
|||
);
|
||||
}
|
||||
|
||||
const {trackingID} = googleAnalytics;
|
||||
const {trackingID, anonymizeIP} = googleAnalytics;
|
||||
|
||||
if (!trackingID) {
|
||||
throw new Error(
|
||||
|
@ -53,6 +53,7 @@ module.exports = function(context) {
|
|||
innerHTML: `
|
||||
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
|
||||
ga('create', '${trackingID}', 'auto');
|
||||
ga('set', 'anonymizeIp', ${anonymizeIP});
|
||||
ga('send', 'pageview');
|
||||
`,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue