diff --git a/src/nationalarchives/analytics.mjs b/src/nationalarchives/analytics.mjs index a1c69d2f..7beede0a 100644 --- a/src/nationalarchives/analytics.mjs +++ b/src/nationalarchives/analytics.mjs @@ -5,12 +5,14 @@ import { valueGetters, } from "./lib/analytics-helpers.mjs"; import BreadcrumbAnalytics from "./components/breadcrumbs/analytics.js"; +import GlobalHeaderAnalytics from "./components/global-header/analytics.js"; import HeaderAnalytics from "./components/header/analytics.js"; import HeroAnalytics from "./components/hero/analytics.js"; import PictureAnalytics from "./components/picture/analytics.js"; const componentAnalytics = [ ...BreadcrumbAnalytics, + ...GlobalHeaderAnalytics, ...HeaderAnalytics, ...HeroAnalytics, ...PictureAnalytics, diff --git a/src/nationalarchives/components/global-header/analytics.js b/src/nationalarchives/components/global-header/analytics.js new file mode 100644 index 00000000..92a37a92 --- /dev/null +++ b/src/nationalarchives/components/global-header/analytics.js @@ -0,0 +1,23 @@ +export default [ + { + scope: ".tna-global-header", + areaName: "header", + events: [ + { + eventName: "toggle", + targetElement: ".tna-global-header__navigation-button", + on: "click", + data: { + // eslint-disable-next-line no-unused-vars + state: ($el, $scope, event) => { + const expanded = $el.getAttribute("aria-expanded"); + if (expanded === null) { + return null; + } + return expanded.toString() === "true" ? "opened" : "closed"; + }, + }, + }, + ], + }, +];