generated from NYCPlanning/ae-remix-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Track navigation to external websites - Track navigation to interal pages - Track changing of district type closes #38
- Loading branch information
1 parent
13bc332
commit bce9648
Showing
5 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ node_modules | |
/blob-report/ | ||
/playwright/.cache/ | ||
.vscode | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export function analytics(eventData) { | ||
if (eventData.value) { | ||
window._paq.push([ | ||
"trackEvent", | ||
eventData.category, | ||
eventData.action, | ||
eventData.name, | ||
eventData.value, | ||
]); | ||
} else { | ||
window._paq.push([ | ||
"trackEvent", | ||
eventData.category, | ||
eventData.action, | ||
eventData.name, | ||
]); | ||
} | ||
} | ||
|
||
export function initializeMatomoTagManager(containerID) { | ||
// From the initial script they provide for setup | ||
var _mtm = (window._mtm = window._mtm || []); | ||
_mtm.push({ "mtm.startTime": new Date().getTime(), event: "mtm.Start" }); | ||
var d = document, | ||
g = d.createElement("script"), | ||
s = d.getElementsByTagName("script")[0]; | ||
g.type = "text/javascript"; | ||
g.id = "matomo-tag-manager"; | ||
g.async = true; | ||
g.src = `https://cdn.matomo.cloud/nycplanning.matomo.cloud/container_${containerID}.js`; | ||
s.parentNode.insertBefore(g, s); | ||
|
||
// To track pageviews, watching for changes to location.pathname | ||
let previousUrlPath = location.pathname; | ||
const observer = new MutationObserver(function () { | ||
if (location.pathname !== previousUrlPath) { | ||
previousUrlPath = location.pathname; | ||
window._paq.push(["setCustomUrl", location.href]); | ||
window._paq.push(["trackPageView"]); | ||
} | ||
}); | ||
const config = { subtree: true, childList: true }; | ||
observer.observe(document, config); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters