Skip to content

Commit

Permalink
Add tracking for global header
Browse files Browse the repository at this point in the history
  • Loading branch information
ahosgood committed Feb 14, 2024
1 parent ca022fc commit 58a81f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/nationalarchives/analytics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions src/nationalarchives/components/global-header/analytics.js
Original file line number Diff line number Diff line change
@@ -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";
},
},
},
],
},
];

0 comments on commit 58a81f9

Please sign in to comment.