Skip to content

Commit

Permalink
[website] Sample GA to avoid hit limit
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 5, 2022
1 parent 27f1c28 commit a06f69b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/pages/_document.js
Expand Up @@ -29,7 +29,7 @@ if (process.env.NODE_ENV === 'production') {
cleanCSS = new CleanCSS();
}

const GOOGLE_ID = process.env.NODE_ENV === 'production' ? 'UA-106598593-2' : 'UA-106598593-3';
const GOOGLE_ID = process.env.PULL_REQUEST === 'true' ? 'UA-106598593-2' : 'UA-106598593-3';

export default class MyDocument extends Document {
render() {
Expand Down Expand Up @@ -140,7 +140,9 @@ export default class MyDocument extends Document {
dangerouslySetInnerHTML={{
__html: `
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
window.ga('create','${GOOGLE_ID}','auto');
window.ga('create','${GOOGLE_ID}',{
sampleRate: ${process.env.PULL_REQUEST === 'true' ? 100 : 80},
});
`,
}}
/>
Expand Down

0 comments on commit a06f69b

Please sign in to comment.