使用谷歌分析跟踪重定向页面 [英] track a redirect page with google analytics

查看:32
本文介绍了使用谷歌分析跟踪重定向页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用谷歌分析跟踪重定向页面:
我有一个名为 redirect.php 的页面;当我访问像 redirect.php?c=12345678 这样的 url 时,php 函数会在 sql 查找表上进行查询,以使用先前插入的 url 解码代码 12345678,然后进行 301 重定向.

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 , a php function does a query on a sql lookup table to decode the code 12345678 with a previously inserted url, then does a 301 redirect.

(我正在执行 301 重定向以避免重复内容.)
我希望通过分析跟踪对 redirect.php 的每次访问,但我不能.

(I'm doing a 301 redirect to avoid duplicate content.)
I wish to track every single visit to redirect.php with analytics, but I can't.

例如:

redirect.php?c=87654321 重定向到 story.php.

显然在 Analytics 中我找不到 redirect.php 页面.story.php 引用是 organic/google 所以我不能依赖引用.

Obviously in Analytics I can't find the redirect.php page. the story.php referer is organic/google so I can't rely on the referer.

是否可以通过某些方式跟踪每个重定向?

Is it possible to track every redirect in some ways?

推荐答案

GA 在浏览器中工作.每当用户访问带有 GA 脚本的页面时,都会向 google 发送用户请求,通知有关该访问的信息.由于您正在进行 301 标头重定向 - 没有加载 GA 脚本,因此谷歌不知道用户已经在该页面上.

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.

您拥有的选项

  • 将重定向从 301 标头切换到带有元重定向和 GA 代码的页面
  • 切换到另一个分析系统(例如 Piwik)并在重定向页面上手动添加数据
  • 在重定向脚本中实现自己的计数器,与 GA 分离

当然,您可以合并选项并拥有一个带有元重定向和 GA 代码的页面,该页面重定向到 redirect.php 脚本,该脚本又使用 301 标头重定向,但这不是最佳解决方案.

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.

这篇关于使用谷歌分析跟踪重定向页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆