mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-17 11:07:07 +02:00
Allow Google Analytics to use gtag.js (#601)
* Moved google analytics script to head The code now uses the new gtag script to track the website on google analytics. The migration is explained [here](https://developers.google.com/analytics/devguides/collection/gtagjs/migration). This will help to solve issues such as #375. As indicated at https://support.google.com/analytics/answer/1008080 the analytics code must be placed in the head tag, so it is moved there. * Add a boolean to use the new gtag library * Update api-site-config.md
This commit is contained in:
parent
ae53bdc46a
commit
976ae770b5
3 changed files with 40 additions and 15 deletions
|
@ -83,21 +83,6 @@ class Site extends React.Component {
|
|||
src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"
|
||||
/>
|
||||
)}
|
||||
{this.props.config.gaTrackingId && (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', '${this.props.config.gaTrackingId}', 'auto');
|
||||
ga('send', 'pageview');
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{this.props.config.facebookAppId && (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue