diff --git a/layouts/_default/search.html b/layouts/_default/search.html index 5c299c92cee4..3192eaadaa4b 100644 --- a/layouts/_default/search.html +++ b/layouts/_default/search.html @@ -1,185 +1,191 @@ -{{ define "left" }} - {{ partial "sidebar/mainnav.html" . }} -{{ end }} - -{{ define "main" }} -
-

{{ .Title }}

- {{ .Content }} -
-
- -
-

Not finding what you're looking for? Try

- -
-
-
-
- +{{ define "left" }}{{ partial "sidebar/mainnav.html" . }}{{ end }} {{ define +"main" }} +
+

{{ .Title }}

+ {{ .Content }} +
+
+ +
+

+ Not finding what you're looking for? Try +

+
-
- + } + + searchPageInput.addEventListener("input", (e) => onPageSearch(e)); + + // Event delegation for tracking link clicks + if (window.heap !== undefined) { + searchPageResults.addEventListener("click", function (event) { + if (event.target.tagName === "A" && event.target.closest(".link")) { + const searchQuery = event.target.getAttribute("data-query"); + const resultIndex = event.target.getAttribute("data-index"); + const url = new URL(event.target.href); + const properties = { + docs_search_target_path: url.pathname, + docs_search_target_title: event.target.textContent, + docs_search_query_text: searchQuery, + docs_search_target_index: resultIndex, + docs_search_source_path: window.location.pathname, + docs_search_source_title: document.title, + }; + heap.track("Docs - Search - Click - Result Link", properties); + } + }); + } + {{ end }} diff --git a/layouts/partials/search-bar.html b/layouts/partials/search-bar.html index a51bc8a82687..5d571e051c5a 100644 --- a/layouts/partials/search-bar.html +++ b/layouts/partials/search-bar.html @@ -1,21 +1,21 @@