Skip to content

Commit bcc0829

Browse files
dandimeodandimeoSimran-B
authored
[DOC-588] Add tracking managers (#257)
* create tracking partisls * add tracking partials call to head * fix tracking partials invoke * add body start and end tracking managers * use tracking managers only when site is production * Factor out body tracking code, fix/cleanup layout * Fix tracking partial path * Whitespace * Remove tracking (utm_*) from cloud.arangodb.com/home links in local and preview builds * Refactor page tracking * Don't track hashchange event * Remove unnecessary use of base URL * Exclude hash-only changes from tracking in updateHistory() * Use $isProduction variable to be self-descriptive * Temporarily invert logic for testing * Remove ZoomInfo * Cleanup * Revert "Temporarily invert logic for testing" This reverts commit 239f75b. * Add noscript remark that JavaScript is required --------- Co-authored-by: dandimeo <[email protected]> Co-authored-by: Simran Spiller <[email protected]>
1 parent 2107ba2 commit bcc0829

File tree

14 files changed

+165
-110
lines changed

14 files changed

+165
-110
lines changed

site/themes/arangodb-docs-theme/layouts/404.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</head>
1111

1212
<body>
13+
<noscript>You need to enable JavaScript to use the ArangoDB documentation.</noscript>
1314
<div id="page-wrapper" class="page_content_splash" style="height: auto;opacity: 0;">
1415
<section id="page-main">
1516
<section class="page-container" id="page-container">

site/themes/arangodb-docs-theme/layouts/_default/_markup/render-link.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
{{- $isRemote := ne $url.Scheme "" }}
1212

1313
{{ if $isRemote -}}
14-
{{ $permalink = .Destination -}}
14+
{{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" }}
15+
{{ if and (not $isProduction) (eq .Destination "https://cloud.arangodb.com/home?utm_source=docs&utm_medium=cluster_pages&utm_campaign=docs_traffic") -}}
16+
{{ $permalink = "https://cloud.arangodb.com/home" -}}
17+
{{ else -}}
18+
{{ $permalink = .Destination -}}
19+
{{ end -}}
1520
{{ else -}}
1621
{{ $isOnlyFragment := findRE `(?m)^#` $link }}
1722
{{ if $isOnlyFragment }}
Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,27 @@
1-
{{- partial "shortcodes/version.html" (dict "page" .Page ) }}
2-
3-
1+
{{ partial "shortcodes/version.html" (dict "page" .Page) -}}
2+
{{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" -}}
43
<!DOCTYPE html>
5-
<html lang='{{ .Page.Language | default "en" }}'>
6-
{{- partial "head.html" . }}
7-
4+
<html lang="{{ .Page.Language | default "en" }}">
5+
{{ partial "head.html" . -}}
86
<body>
9-
<div
10-
id="page-wrapper"
11-
class="page_content_splash"
12-
style="height: auto; opacity: 0"
13-
>
7+
{{ if $isProduction }}{{ partial "tracking/body-start.html" . }}{{ end -}}
8+
<noscript>You need to enable JavaScript to use the ArangoDB documentation.</noscript>
9+
<div id="page-wrapper" class="page_content_splash" style="height: auto; opacity: 0">
1410
<section id="page-main">
1511
<section class="page-container" id="page-container">
16-
{{ partial "header.html" . }}
17-
<iframe
18-
src="/nav.html"
19-
title="description"
20-
id="menu-iframe"
21-
class="menu-iframe active"
22-
style="opacity: 0"
23-
></iframe>
24-
12+
{{ partial "header.html" . -}}
13+
<iframe src="/nav.html" title="description" id="menu-iframe" class="menu-iframe active" style="opacity: 0"></iframe>
2514
<div class="container-main">
2615
<div class="row-main">
27-
{{ partial "breadcrumbs.html" . }} {{- partial
28-
"output-partial.hugo" (dict "base" "body" "page" . "parameter"
29-
(dict "page" . "content" (partial "output-partial.hugo" (dict
30-
"base" "content" "page" . "parameter" .)))) }} {{ partial
31-
"toc.html" . }}
16+
{{ partial "breadcrumbs.html" . -}}
17+
{{ partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) }}
18+
{{ partial "toc.html" . -}}
3219
</div>
3320
</div>
3421
</section>
3522
</section>
3623
</div>
37-
{{ partial "search.html" . }}
24+
{{ partial "search.html" . -}}
25+
{{ if $isProduction }}{{ partial "tracking/body-end.html" . }}{{ end -}}
3826
</body>
3927
</html>
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
{{- partial "shortcodes/version.html" (dict
2-
"page" .Page
3-
) }}
1+
{{- partial "shortcodes/version.html" (dict "page" .Page) -}}
2+
{{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" -}}
43

54
<!DOCTYPE html>
65
<html lang="{{ .Page.Language | default "en" }}">
7-
8-
{{- partial "head.html" . }}
9-
10-
<body>
6+
{{ partial "head.html" . -}}
7+
<body>
8+
{{ if $isProduction }}{{ partial "tracking/body-start.html" . }}{{ end -}}
9+
<noscript>You need to enable JavaScript to use the ArangoDB documentation.</noscript>
1110
<div id="page-wrapper" class="page_content_splash" style="height: auto;opacity: 0;">
12-
<section id="page-main">
13-
<section class="page-container" id="page-container">
14-
{{ partial "header.html" . }}
15-
<iframe src="/nav.html" title="description" id="menu-iframe" class="menu-iframe active" style="opacity: 0;"></iframe>
16-
17-
18-
<div class="container-main">
19-
<div class="row-main">
20-
{{ if gt (len .Page.Ancestors) 1 }}{{ partial "breadcrumbs.html" . }}{{ end }}
21-
{{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) }}
22-
{{ partial "toc.html" . }}
23-
</div>
24-
</main><!-- #body-inner -->
25-
</div><!-- #body -->
26-
{{- partialCached "back-to-top.html" . }}
27-
{{ partial "search.html" . }}
28-
</body>
29-
30-
</html>
11+
<section id="page-main">
12+
<section class="page-container" id="page-container">
13+
{{ partial "header.html" . -}}
14+
<iframe src="/nav.html" title="description" id="menu-iframe" class="menu-iframe active" style="opacity: 0;"></iframe>
15+
<div class="container-main">
16+
<div class="row-main">
17+
{{ if gt (len .Page.Ancestors) 1 }}{{ partial "breadcrumbs.html" . }}{{ end -}}
18+
{{ partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) -}}
19+
{{ partial "toc.html" . -}}
20+
</div>
21+
</div>
22+
</section>
23+
</section>
24+
</div>
25+
{{ partialCached "back-to-top.html" . -}}
26+
{{ partial "search.html" . -}}
27+
{{ if $isProduction }}{{ partial "tracking/body-end.html" . }}{{ end -}}
28+
</body>
29+
</html>
Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
1-
{{- partial "shortcodes/version.html" (dict
2-
"page" .Page
3-
) }}
4-
1+
{{ partial "shortcodes/version.html" (dict "page" .Page) -}}
2+
{{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" -}}
53

64
<!DOCTYPE html>
75
<html lang="{{ .Page.Language | default "en" }}">
8-
9-
{{- partial "head.html" . }}
10-
11-
<body>
6+
{{ partial "head.html" . -}}
7+
<body>
8+
{{ if $isProduction }}{{ partial "tracking/body-start.html" . }}{{ end -}}
9+
<noscript>You need to enable JavaScript to use the ArangoDB documentation.</noscript>
1210
<div id="page-wrapper" class="page_content_splash" style="height: auto;opacity: 0;">
13-
<section id="page-main">
14-
<section class="page-container" id="page-container">
15-
{{ partial "header.html" . }}
16-
<iframe src="/nav.html" title="description" id="menu-iframe" class="menu-iframe active" style="opacity: 0;"></iframe>
17-
18-
19-
<div class="container-main">
20-
<div class="row-main">
21-
{{ partial "breadcrumbs.html" . }}
22-
{{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) }}
23-
{{ partial "toc.html" . }}
24-
</div>
25-
</main><!-- #body-inner -->
26-
</div><!-- #body -->
27-
{{- partial "back-to-top.html" . }}
28-
{{ partial "search.html" . }}
29-
</body>
30-
</html>
11+
<section id="page-main">
12+
<section class="page-container" id="page-container">
13+
{{ partial "header.html" . -}}
14+
<iframe src="/nav.html" title="description" id="menu-iframe" class="menu-iframe active" style="opacity: 0;"></iframe>
15+
<div class="container-main">
16+
<div class="row-main">
17+
{{ partial "breadcrumbs.html" . -}}
18+
{{ partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) -}}
19+
{{ partial "toc.html" . -}}
20+
</div>
21+
</div>
22+
</section>
23+
</section>
24+
</div>
25+
{{ partialCached "back-to-top.html" . -}}
26+
{{ partial "search.html" . -}}
27+
{{ if $isProduction }}{{ partial "tracking/body-end.html" . }}{{ end -}}
28+
</body>
29+
</html>
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<head>
2-
{{- partial "stylesheet.html" . }}
2+
{{ partial "stylesheet.html" . -}}
33

4-
{{- partial "meta.html" . }}
5-
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
6-
<title>{{ if and .Title (not (eq .Title .Site.Title)) }}{{ .Title | markdownify | plainify | safeHTML }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Site.Title }}</title>
4+
{{ partial "meta.html" . -}}
5+
<title>{{ if and .Title (not (eq .Title .Site.Title)) }}{{ .Title | markdownify | plainify | safeHTML }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Site.Title }}</title>
6+
<link href="{{ "/images/favicon.png" | relURL }}" rel="icon" type="image/png">
7+
{{ partial "javascript.html" . -}}
78

8-
<link href="{{ "/images/favicon.png" | relURL }}" rel="icon" type="image/png">
9-
{{- partial "javascript.html" . }}
10-
11-
12-
</head>
9+
{{ $isProduction := eq site.BaseURL "https://docs.arangodb.com" -}}
10+
{{ if $isProduction -}}
11+
{{- partial "tracking/gtag.html" . -}}
12+
{{- partial "tracking/gtm.html" . -}}
13+
{{- partial "tracking/ga.html" . -}}
14+
{{- partial "tracking/twitter.html" . -}}
15+
{{- partial "tracking/linkedin.html" . -}}
16+
{{ end -}}
17+
</head>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script id="hs-script-loader" async defer src="//js.hs-scripts.com/2482448.js"></script>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-5LQ7HC" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
2+
<noscript><img height="1" width="1" style="display:none;" alt="" src="https://dc.ads.linkedin.com/collect/?pid=499017&fmt=gif"></noscript>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script>
2+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
3+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
4+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
5+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
6+
7+
ga('provide', 'adblockTracker', function(tracker, opts) {
8+
var ad = document.createElement('ins');
9+
ad.className = 'AdSense';
10+
ad.style.display = 'block';
11+
ad.style.position = 'absolute';
12+
ad.style.top = '-1px';
13+
ad.style.height = '1px';
14+
document.body.appendChild(ad);
15+
tracker.set('dimension' + opts.dimensionIndex, !ad.clientHeight);
16+
document.body.removeChild(ad);
17+
});
18+
19+
ga('create', 'UA-81053435-6', 'auto');
20+
ga('require', 'adblockTracker', {dimensionIndex: 1});
21+
ga('send', 'pageview');
22+
</script>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-81053435-1"></script>
2+
<script>
3+
window.dataLayer = window.dataLayer || [];
4+
function gtag(){dataLayer.push(arguments);}
5+
gtag('js', new Date());
6+
gtag('config', 'UA-81053435-1');
7+
</script>

0 commit comments

Comments
 (0)