Skip to content

Commit

Permalink
feat: enable google analytics with _googleAnalyticsTagId (#8733)
Browse files Browse the repository at this point in the history
* feat: enable google analytics with _googleAnalyticsTagId

* test(snapshot): update snapshots for 3d7f25d

---------

Co-authored-by: yufeih <[email protected]>
  • Loading branch information
yufeih and yufeih authored May 5, 2023
1 parent 2fb03c1 commit bc93339
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"globalMetadata": {
"_appTitle": "docfx",
"_appName": "docfx",
"_appFooter": "<span>Supported by the <a href=\"https://dotnetfoundation.org\">.NET Foundation</a>. Made with <a href=\"https://dotnet.github.io/docfx\">docfx</a></span>"
"_appFooter": "<span>Supported by the <a href=\"https://dotnetfoundation.org\">.NET Foundation</a>. Made with <a href=\"https://dotnet.github.io/docfx\">docfx</a></span>",
"_googleTagId": "G-Q5N6XJHEX5"
},
"output": "_site",
"template": [
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Name | Type | Description
`_disableNewTab` | bool | Whether to render external link indicator icons and open external links in a new tab.
`_disableNextArticle` | bool | Whether to show the previous and next article link.
`_disableTocFilter` | bool | Whether to show the table of content filter box.
`lang` | string | Primary language of the page. If unset, the `<html>` tag will not have `lang` property.
`_googleTagId` | string | Enables Google Analytics web traffic analysis.
`lang` | string | Primary language of the page. If unset, the `<html>` tag will not have `lang` property.
`layout` | string | Determines the layout of the page. Supported values are `landing` and `chromeless`.

# [Default Template](#tab/default)
Expand Down
10 changes: 10 additions & 0 deletions templates/modern/layout/_master.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
{{/redirect_url}}
</head>

{{#_googleTagId}}
<script async src="https://www.googletagmanager.com/gtag/js?id={{_googleTagId}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '{{_googleTagId}}');
</script>
{{/_googleTagId}}

{{^redirect_url}}
<body class="tex2jax_ignore" data-layout="{{layout}}" data-yaml-mime="{{yamlmime}}">
<header class="bg-body border-bottom">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference" data-search="true">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="landing" data-yaml-mime="">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
}
</style></head>


<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
Expand Down

0 comments on commit bc93339

Please sign in to comment.