Add participant name to page title for Matomo tracking

This commit is contained in:
2026-01-06 08:54:19 +01:00
parent 60a3159996
commit 6871126788
2 changed files with 13 additions and 2 deletions

View File

@@ -167,8 +167,9 @@ if (isProduction) {
// Insert OG tags before </head> // Insert OG tags before </head>
html = html.replace('</head>', `${ogTags}</head>`); html = html.replace('</head>', `${ogTags}</head>`);
// Update title // Update title - include participant name for Matomo tracking
html = html.replace(/<title>.*?<\/title>/, `<title>${title} - Activiteiten Inventaris</title>`); const pageTitle = `${title} - ${participant.name}`;
html = html.replace(/<title>.*?<\/title>/, `<title>${pageTitle}</title>`);
res.send(html); res.send(html);
}); });

View File

@@ -65,6 +65,16 @@ export function PublicQuestionnaire({ accessToken }: { accessToken?: string } =
fetchQuestionnaire() fetchQuestionnaire()
}, [slug, effectiveToken]) }, [slug, effectiveToken])
// Update document title for Matomo tracking
useEffect(() => {
if (questionnaire) {
const title = visitorName
? `${questionnaire.title} - ${visitorName}`
: questionnaire.title
document.title = title
}
}, [questionnaire, visitorName])
async function fetchQuestionnaire() { async function fetchQuestionnaire() {
try { try {
// Use token-based access if available // Use token-based access if available