aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Blinkov <ivan@ydb.tech>2023-10-03 08:38:11 +0300
committerblinkov <blinkov@yandex-team.com>2023-10-03 08:53:17 +0300
commit87bae6a307005441ec243ca9cbae9b3df161c282 (patch)
tree7d182984a96bf2d31b21f0ba4735bfb2ecccf36a
parent554662d0f043faf247b4757972da608e2785130b (diff)
downloadydb-87bae6a307005441ec243ca9cbae9b3df161c282.tar.gz
[docs] add GTM script
[docs] add GTM script Pull Request resolved: https://github.com/ydb-platform/ydb/pull/383
-rw-r--r--ydb/docs/.yfm3
-rw-r--r--ydb/docs/_assets/gtm.js24
2 files changed, 27 insertions, 0 deletions
diff --git a/ydb/docs/.yfm b/ydb/docs/.yfm
index 82e7efd702..8ffbb54b4d 100644
--- a/ydb/docs/.yfm
+++ b/ydb/docs/.yfm
@@ -1,6 +1,9 @@
allowHTML: true
langs: ['en','ru']
apply-presets: true
+resources:
+ script:
+ - _assets/gtm.js
docs-viewer:
project-name: ydb
diff --git a/ydb/docs/_assets/gtm.js b/ydb/docs/_assets/gtm.js
new file mode 100644
index 0000000000..0e934d75e3
--- /dev/null
+++ b/ydb/docs/_assets/gtm.js
@@ -0,0 +1,24 @@
+// Define dataLayer and the gtag function.
+window.dataLayer = window.dataLayer || [];
+function gtag(){dataLayer.push(arguments);}
+
+// Default analytics_storage to 'denied'.
+window.gtag = window.gtag || gtag;
+
+const hasAnalyticsConsent = window?.localStorage.getItem('hasAnalyticsConsent');
+
+window.gtag('consent', 'default', {
+ 'analytics_storage': hasAnalyticsConsent === 'true' ? 'granted' : 'denied',
+ 'wait_for_update': hasAnalyticsConsent === 'true' ? 0 : Infinity,
+});
+
+dataLayer.push({
+ 'event': 'default_consent'
+});
+
+function loadGtm(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
+new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
+j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
+'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);};
+
+loadGtm(window, document, 'script', 'dataLayer', 'GTM-W7ZBL4X')