diff --git a/packages/site-analytics/demo/index.html b/packages/site-analytics/demo/index.html index 26fb57b88..937a32bae 100644 --- a/packages/site-analytics/demo/index.html +++ b/packages/site-analytics/demo/index.html @@ -1,50 +1,57 @@ + - - - Demo site-analytics page + + + Demo site-analytics page + -
-
- Log page view
- Log another page view with custom title - +
+
+ Log page view
+ Log another page view with custom title + - + // Event delegation for anchor tags + document.body.addEventListener('click', (e) => { + if (e.target.matches('.pageLink')) { + e.preventDefault(); + let customTitle = e.target.getAttribute('data-title'); + e.target.dispatchEvent(new CustomEvent("site-analytics-pageview", { + bubbles: true, + detail: customTitle ? { customTitle: customTitle } : {} + })); + } + }); + + diff --git a/packages/site-analytics/demo/page1.html b/packages/site-analytics/demo/page1.html index e0a596f66..a7ed733a4 100644 --- a/packages/site-analytics/demo/page1.html +++ b/packages/site-analytics/demo/page1.html @@ -1,20 +1,23 @@ + - - - Demo uvalib-analytics page 1 + + + Demo uvalib-analytics page 1 + - Page 2
- + Page 2
+ - + + diff --git a/packages/site-analytics/demo/page2.html b/packages/site-analytics/demo/page2.html index 3f0c53b26..fa4df82a6 100644 --- a/packages/site-analytics/demo/page2.html +++ b/packages/site-analytics/demo/page2.html @@ -1,20 +1,23 @@ + - - - Demo site-analytics page 2 + + + Demo site-analytics page 2 + - Page 1
- + Page 1
+ - + +