track a redirect page with google analytics

后端 未结 2 1813
悲哀的现实
悲哀的现实 2021-01-19 01:45

I am trying to track a redirect page with google analytics:
I have a page called redirect.php; when I visit an url like redirect.php?c=12345678

2条回答
  •  天涯浪人
    2021-01-19 02:39

    GA works in the browser. Whenever the user visits a page with the GA script - a request from the user to google is sent notifying about the visit. Since you are making a 301 header redirect - no GA script is loaded and therefore google doesn't know the user has been on that page.

    Options you have

    • Switch the redirect from 301 header to a page with meta redirect and the GA code
    • Switch to another analytics system such as Piwik and add data to it manually on the redirect page
    • Implement your own counter inside the redirect script, separated from GA

    Of course you could merge the options and have, say a page with meta redirect and the GA code, which redirects to redirect.php script, which in turn redirects with a 301 header, but this is not the best solution.

提交回复
热议问题