Skip to content

Commit

Permalink
Docs: add google analytics, baidu and clarity (#1629)
Browse files Browse the repository at this point in the history
Signed-off-by: Carson Yang <[email protected]>
  • Loading branch information
yangchuansheng authored May 29, 2024
1 parent 1db8161 commit ced23e1
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docSite/hugo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baseURL = "/"
baseURL = "fastgpt.in"
languageCode = "en-GB"
contentDir = "content"
enableEmoji = true
Expand Down
18 changes: 18 additions & 0 deletions docSite/layouts/partials/docs/analytics/baidu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- baidutongji -->
<script defer>
function loadScriptOnScroll() {
var scrollPosition = window.scrollY || window.pageYOffset;

if (scrollPosition > 100) {
var _hmt = _hmt || [];
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?537c7867df8f9ae2e7147284ec0dbfdd";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);

window.removeEventListener('scroll', loadScriptOnScroll);
}
}

window.addEventListener('scroll', loadScriptOnScroll);
</script>
20 changes: 20 additions & 0 deletions docSite/layouts/partials/docs/analytics/clarity.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Microsoft Clarity -->
<script defer>
function loadClarityScript() {
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "mjgug8s1pf");

window.removeEventListener('scroll', onScrollLoadClarity);
}

function onScrollLoadClarity() {
if (window.scrollY > 100) {
loadClarityScript();
}
}

window.addEventListener('scroll', onScrollLoadClarity);
</script>
26 changes: 26 additions & 0 deletions docSite/layouts/partials/docs/analytics/google.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Google tag (gtag.js) -->
<script defer>
function loadAnalyticsScript() {
var script = document.createElement('script');
script.async = true;
script.src = 'https://gaxy.fastgpt.in/gtag/js?id=G-KGYF44Y7TT';
document.head.appendChild(script);

window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-KGYF44Y7TT');

window.removeEventListener('scroll', onScrollLoadAnalytics);
}

function onScrollLoadAnalytics() {
if (window.scrollY > 100) {
loadAnalyticsScript();
}
}

window.addEventListener('scroll', onScrollLoadAnalytics);
</script>
3 changes: 3 additions & 0 deletions docSite/layouts/partials/docs/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
{{- if not .Site.IsServer }}
{{ with site.Params.umamiAnalytics.websiteid }}
{{- partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "analytics/umami.html") . -}}
{{- partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "analytics/google.html") . -}}
{{- partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "analytics/baidu.html") . -}}
{{- partialCached (printf "%s/%s" ($.Scratch.Get "pathName") "analytics/clarity.html") . -}}
{{ end }}
{{ end }}
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/style.css" as="style" />
Expand Down

0 comments on commit ced23e1

Please sign in to comment.