cloudflare-workers-async-google-analytics icon indicating copy to clipboard operation
cloudflare-workers-async-google-analytics copied to clipboard

Page URL not displaying correctly

Open dorawei opened this issue 3 years ago • 5 comments

After swtiching to CFGA pageview report by url (or Page, default dimension) is not showing the right items, seems all views counted to "/", but Page Title report is showing the correct titles.

Any suggestions would be greatly appreciated...

dorawei avatar Feb 17 '22 15:02 dorawei

metoo

zhouhaixian avatar Mar 12 '22 11:03 zhouhaixian

After swtiching to CFGA pageview report by url (or Page, default dimension) is not showing the right items, seems all views counted to "/", but Page Title report is showing the correct titles.

Any suggestions would be greatly appreciated...

The script doesn't report the URL directly. It relies on the server to read the request from the Referer header (where the page URL should be).

Since the URL hash is meant to stay in the browser only and never be sent to the server, If you are deploying a SPA and using hash-based routing and that might happened.

SukkaW avatar Mar 12 '22 14:03 SukkaW

After swtiching to CFGA pageview report by url (or Page, default dimension) is not showing the right items, seems all views counted to "/", but Page Title report is showing the correct titles. Any suggestions would be greatly appreciated...

The script doesn't report the URL directly. It relies on the server to read the request from the Referer header (where the page URL should be).

Since the URL hash is meant to stay in the browser only and never be sent to the server, If you are deploying a SPA and using hash-based routing and that might happened.

const historyCreator = __VUEPRESS_SSR__ ? createMemoryHistory : createWebHistory;

const router = createRouter({
        history: historyCreator(removeEndingSlash(siteData.value.base)),
        routes: pagesRoutes,
        scrollBehavior: (to, from, savedPosition) => {
            if (savedPosition)
                return savedPosition;
            if (to.hash)
                return { el: to.hash };
            return { top: 0 };
        },
    });

However, I don't seem to use Hash routes.

zhouhaixian avatar Mar 13 '22 03:03 zhouhaixian

After swtiching to CFGA pageview report by url (or Page, default dimension) is not showing the right items, seems all views counted to "/", but Page Title report is showing the correct titles. Any suggestions would be greatly appreciated...

The script doesn't report the URL directly. It relies on the server to read the request from the Referer header (where the page URL should be).

Since the URL hash is meant to stay in the browser only and never be sent to the server, If you are deploying a SPA and using hash-based routing and that might happened.

It's a jekyll site with ordinary URL paths, but still most of the URLs not being captured. Weird thing is approx. 5% of views could be captured with the correct page URLs, the remaining 95% views just go to "/".

Not sure what's wrong with CF's Referer to page_URL... Any plans to implement a client side method of capturing page URLs (dl)?

dorawei avatar Mar 13 '22 06:03 dorawei

I added 'dl=' + encode(document.URL) in "cfga.js" to capture page URLs (dl) and changed const pvData = `...&dl=${encode(page_url)}&...`; to const pvData = `...&dl=${encode(getQueryString('dl'))}&...`; in "worker.js". it works for me

Cesirdy avatar Apr 23 '22 13:04 Cesirdy