From b5b8195cef5587fc6799176a8cb1c5fb9ca61c24 Mon Sep 17 00:00:00 2001 From: esikkala <esko.ikkala@aalto.fi> Date: Sun, 23 Jan 2022 11:33:19 +0200 Subject: [PATCH] Fix usePageViews --- src/client/helpers/helpers.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/client/helpers/helpers.js b/src/client/helpers/helpers.js index 1f615609..9156ce85 100644 --- a/src/client/helpers/helpers.js +++ b/src/client/helpers/helpers.js @@ -314,8 +314,10 @@ export const usePageViews = () => { const location = useLocation() useEffect(() => { if (typeof window.ga === 'function') { - console.log(window.ga) - window.ga.send(['pageview', location.pathname]) + // https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications#tracking_virtual_pageviews + // note: the ga function has been initialized in index.html + window.ga('set', 'page', location.pathname) + window.ga('send', 'pageview') } }, [location]) } -- GitLab