+ {{ if $isProduction }}{{ partial "tracking/body-start.html" . }}{{ end -}}
+
+
- {{ partial "header.html" . }}
-
-
+ {{ partial "header.html" . -}}
+
- {{ partial "breadcrumbs.html" . }} {{- partial
- "output-partial.hugo" (dict "base" "body" "page" . "parameter"
- (dict "page" . "content" (partial "output-partial.hugo" (dict
- "base" "content" "page" . "parameter" .)))) }} {{ partial
- "toc.html" . }}
+ {{ partial "breadcrumbs.html" . -}}
+ {{ partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) }}
+ {{ partial "toc.html" . -}}
- {{ partial "search.html" . }}
+ {{ partial "search.html" . -}}
+ {{ if $isProduction }}{{ partial "tracking/body-end.html" . }}{{ end -}}
diff --git a/site/themes/arangodb-docs-theme/layouts/_default/list.html b/site/themes/arangodb-docs-theme/layouts/_default/list.html
index d565c56a66..bfaf7288da 100644
--- a/site/themes/arangodb-docs-theme/layouts/_default/list.html
+++ b/site/themes/arangodb-docs-theme/layouts/_default/list.html
@@ -1,30 +1,29 @@
-{{- partial "shortcodes/version.html" (dict
- "page" .Page
-) }}
+{{- partial "shortcodes/version.html" (dict "page" .Page) -}}
+{{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" -}}
-
- {{- partial "head.html" . }}
-
-
+ {{ partial "head.html" . -}}
+
+ {{ if $isProduction }}{{ partial "tracking/body-start.html" . }}{{ end -}}
+
-
-
- {{ partial "header.html" . }}
-
-
-
-
-
- {{ if gt (len .Page.Ancestors) 1 }}{{ partial "breadcrumbs.html" . }}{{ end }}
- {{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) }}
- {{ partial "toc.html" . }}
-
-
-
- {{- partialCached "back-to-top.html" . }}
- {{ partial "search.html" . }}
-
-
-
\ No newline at end of file
+
+
+ {{ partial "header.html" . -}}
+
+
+
+ {{ if gt (len .Page.Ancestors) 1 }}{{ partial "breadcrumbs.html" . }}{{ end -}}
+ {{ partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) -}}
+ {{ partial "toc.html" . -}}
+
+
+
+
+
+ {{ partialCached "back-to-top.html" . -}}
+ {{ partial "search.html" . -}}
+ {{ if $isProduction }}{{ partial "tracking/body-end.html" . }}{{ end -}}
+
+
diff --git a/site/themes/arangodb-docs-theme/layouts/_default/single.html b/site/themes/arangodb-docs-theme/layouts/_default/single.html
index e0ce3cf4c0..6fc173a323 100644
--- a/site/themes/arangodb-docs-theme/layouts/_default/single.html
+++ b/site/themes/arangodb-docs-theme/layouts/_default/single.html
@@ -1,30 +1,29 @@
-{{- partial "shortcodes/version.html" (dict
- "page" .Page
-) }}
-
+{{ partial "shortcodes/version.html" (dict "page" .Page) -}}
+{{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" -}}
-
- {{- partial "head.html" . }}
-
-
+ {{ partial "head.html" . -}}
+
+ {{ if $isProduction }}{{ partial "tracking/body-start.html" . }}{{ end -}}
+
-
-
- {{ partial "header.html" . }}
-
-
-
-
-
- {{ partial "breadcrumbs.html" . }}
- {{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) }}
- {{ partial "toc.html" . }}
-
-
-
- {{- partial "back-to-top.html" . }}
- {{ partial "search.html" . }}
-
-
\ No newline at end of file
+
+
+ {{ partial "header.html" . -}}
+
+
+
+ {{ partial "breadcrumbs.html" . -}}
+ {{ partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) -}}
+ {{ partial "toc.html" . -}}
+
+
+
+
+
+ {{ partialCached "back-to-top.html" . -}}
+ {{ partial "search.html" . -}}
+ {{ if $isProduction }}{{ partial "tracking/body-end.html" . }}{{ end -}}
+
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/head.html b/site/themes/arangodb-docs-theme/layouts/partials/head.html
index 89dd33578e..7ae62a1a00 100644
--- a/site/themes/arangodb-docs-theme/layouts/partials/head.html
+++ b/site/themes/arangodb-docs-theme/layouts/partials/head.html
@@ -1,12 +1,17 @@
- {{- partial "stylesheet.html" . }}
+ {{ partial "stylesheet.html" . -}}
- {{- partial "meta.html" . }}
- {{- $link := "
" }}
-
{{ if and .Title (not (eq .Title .Site.Title)) }}{{ .Title | markdownify | plainify | safeHTML }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Site.Title }}
+ {{ partial "meta.html" . -}}
+
{{ if and .Title (not (eq .Title .Site.Title)) }}{{ .Title | markdownify | plainify | safeHTML }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Site.Title }}
+
+ {{ partial "javascript.html" . -}}
-
- {{- partial "javascript.html" . }}
-
-
-
\ No newline at end of file
+ {{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" -}}
+ {{ if $isProduction -}}
+ {{- partial "tracking/gtag.html" . -}}
+ {{- partial "tracking/gtm.html" . -}}
+ {{- partial "tracking/ga.html" . -}}
+ {{- partial "tracking/twitter.html" . -}}
+ {{- partial "tracking/linkedin.html" . -}}
+ {{ end -}}
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/tracking/body-end.html b/site/themes/arangodb-docs-theme/layouts/partials/tracking/body-end.html
new file mode 100644
index 0000000000..b263f38353
--- /dev/null
+++ b/site/themes/arangodb-docs-theme/layouts/partials/tracking/body-end.html
@@ -0,0 +1 @@
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/tracking/body-start.html b/site/themes/arangodb-docs-theme/layouts/partials/tracking/body-start.html
new file mode 100644
index 0000000000..3c8d1bca72
--- /dev/null
+++ b/site/themes/arangodb-docs-theme/layouts/partials/tracking/body-start.html
@@ -0,0 +1,2 @@
+
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/tracking/ga.html b/site/themes/arangodb-docs-theme/layouts/partials/tracking/ga.html
new file mode 100644
index 0000000000..576aed8dea
--- /dev/null
+++ b/site/themes/arangodb-docs-theme/layouts/partials/tracking/ga.html
@@ -0,0 +1,22 @@
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/tracking/gtag.html b/site/themes/arangodb-docs-theme/layouts/partials/tracking/gtag.html
new file mode 100644
index 0000000000..3eb91b9ed4
--- /dev/null
+++ b/site/themes/arangodb-docs-theme/layouts/partials/tracking/gtag.html
@@ -0,0 +1,7 @@
+
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/tracking/gtm.html b/site/themes/arangodb-docs-theme/layouts/partials/tracking/gtm.html
new file mode 100644
index 0000000000..66f8aa8550
--- /dev/null
+++ b/site/themes/arangodb-docs-theme/layouts/partials/tracking/gtm.html
@@ -0,0 +1,6 @@
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/tracking/linkedin.html b/site/themes/arangodb-docs-theme/layouts/partials/tracking/linkedin.html
new file mode 100644
index 0000000000..795c95d968
--- /dev/null
+++ b/site/themes/arangodb-docs-theme/layouts/partials/tracking/linkedin.html
@@ -0,0 +1,12 @@
+
+
diff --git a/site/themes/arangodb-docs-theme/layouts/partials/tracking/twitter.html b/site/themes/arangodb-docs-theme/layouts/partials/tracking/twitter.html
new file mode 100644
index 0000000000..f6c4bc6300
--- /dev/null
+++ b/site/themes/arangodb-docs-theme/layouts/partials/tracking/twitter.html
@@ -0,0 +1,7 @@
+
diff --git a/site/themes/arangodb-docs-theme/static/js/theme.js b/site/themes/arangodb-docs-theme/static/js/theme.js
index a76b8303c9..3b8b20aef8 100644
--- a/site/themes/arangodb-docs-theme/static/js/theme.js
+++ b/site/themes/arangodb-docs-theme/static/js/theme.js
@@ -27,7 +27,7 @@ function menuEntryClickListener() {
return
}
console.log(event.target)
- updateHistory("", event.target.getAttribute('href'))
+ updateHistory(event.target.getAttribute('href'))
$('#sidebar.mobile').removeClass("active")
});
@@ -109,17 +109,15 @@ function replaceArticle(href, newDoc) {
}
-function updateHistory(title, url) {
- console.log("Update History " + url)
- if (url == window.location.href) {
+function updateHistory(urlPath) {
+ console.log("Update History " + urlPath)
+ if (urlPath == window.location.pathname + window.location.hash) {
return
}
- window.history.pushState("navchange", "ArangoDB Documentation", url);
+ window.history.pushState("navchange", "ArangoDB Documentation", urlPath);
+ if (!urlPath.startsWith("#")) trackPageView(document.title, urlPath);
- var _hsq = window._hsq = window._hsq || [];
- _hsq.push(['setPath', url]);
- _hsq.push(['trackPageView']);
var popStateEvent = new PopStateEvent('popstate', { state: "navchange" });
dispatchEvent(popStateEvent);
}
@@ -181,7 +179,7 @@ function internalLinkListener() {
return;
}
event.preventDefault();
- updateHistory("", event.target.getAttribute('href'))
+ updateHistory(event.target.getAttribute('href'))
})
}
@@ -193,7 +191,18 @@ function codeShowMoreListener() {
})
}
+function trackPageView(title, urlPath) {
+ if (window.gtag) {
+ gtag('config', 'UA-81053435-1', {
+ 'page_title': title,
+ 'page_path': urlPath
+ });
+ }
+ var _hsq = window._hsq = window._hsq || [];
+ _hsq.push(['setPath', urlPath]);
+ _hsq.push(['trackPageView']);
+}
function initArticle(url) {
restoreTabSelections();
@@ -220,11 +229,6 @@ $(window).on('popstate', function (e) {
$(window).on('hashchange', function (e) {
window.history.pushState("popstate", "ArangoDB Documentation", window.location.href);
-
- var _hsq = window._hsq = window._hsq || [];
- _hsq.push(['setPath', window.location.href]);
- _hsq.push(['trackPageView']);
-
scrollToFragment()
});
@@ -419,9 +423,9 @@ function changeVersion() {
}
- var newUrl = window.location.href.replace(getVersionByURL(), getVersionInfo(newVersion).alias)
+ var newUrl = window.location.pathname.replace(getVersionByURL(), getVersionInfo(newVersion).alias) + window.location.hash;
console.log("Change Version URL " + newUrl)
- updateHistory("", newUrl);
+ updateHistory(newUrl);
}
@@ -517,8 +521,8 @@ const goToTop = (event) => {
function goToHomepage(event){
event.preventDefault();
- var homepage = window.location.origin + "/" + getVersionByURL() + "/";
- updateHistory("", homepage);
+ var homepage = "/" + getVersionByURL() + "/";
+ updateHistory(homepage);
}
function copyURI(evt) {
@@ -544,10 +548,7 @@ function toggleExpandShortcode(event) {
window.onload = () => {
window.history.pushState("popstate", "ArangoDB Documentation", window.location.href);
-
- var _hsq = window._hsq = window._hsq || [];
- _hsq.push(['setPath', window.location.href]);
- _hsq.push(['trackPageView']);
+ trackPageView(document.title, window.location.pathname);
var iframe = document.getElementById('menu-iframe');
var iFrameBody = iframe.contentDocument || iframe.contentWindow.document;