重定向HTTP引荐 [英] HTTP Referrer on Redirection

查看:147
本文介绍了重定向HTTP引荐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小脚本,可以将用户重定向到主站点,如果它们来自我/其他远程站点上的横幅。

 < ;? 

..
...
....
header(location:$ golink);
?>

但谷歌分析不会显示引荐网站(脚本正在工作的地方),而是显示网址点击横幅的地方。很显然,我无法保持横幅出现和不想要的所有网站的跟踪。我希望refferer成为脚本工作的网站。我如何使用 $ _ SERVER ['HTTP_REFERER']; 来做到这一点?

解决方案

GA有一种方法可让您访问用指定的值覆盖默认引用URL (document.referrer)。



因此,如果您想保留重定向服务器端,您可以在header()调用中追加引用URL作为查询字符串参数,然后查找它在目标页面上,并指定它作为引用的URL。

我不知道你是如何构建你的$ golink变量的,但基本上你会添加一些东西的:



$ golink。=?ref =。 $ _SERVER ['HTTP_REFERER'];



使用& code>?如果已经有URL参数,并且上面的代码假设使用 ref 作为URL参数,那么使用任何var想。



然后在您的目标网页上,在 _trackPageview 调用之前,您可以添加

_gaq.push(['_ setReferrerOverride',ref]);



ref 将是一个javascript变量,其值为ref = xxx查询字符串param。由于一些奇怪的原因,Javascript没有原生的方式来获取URL参数值,GA也没有提供(暴露)解决方案。如果你已经在你的页面上有一个解决方案来抓取URL参数(比如你已经创建的框架或函数中的某些东西),那就使用它。否则,很容易找到一个可以为你做的javascript函数。



有这样做的好处:


  1. 不必担心访问者看到插页式页面。

  2. 您无需担心GA在重定向之前无法完全加载。

  3. 您可以看到直接与您的目标网页相关联的推荐链接,因为在插页式广告页面中,您始终会将插页式网页看作推荐链接,并且必须查看插页式广告网页的引荐网址报告。


I have a small script that redirects users to main site if they come from a banner on my/other remote sites.

<?
.
..
...
....
header("location:$golink"); 
?>

But google analytics will not show the referrer site (where the script is working) instead it shows the url where the banner is clicked. Obviously I can not keep a track of all sites where banner appears and dont want to. I want the refferer to be the site where the script is working. How do I have to use the $_SERVER['HTTP_REFERER']; in order to do this ?

解决方案

GA has a method that will let you to override the default referring URL (document.referrer) with a specified value.

So if you want to keep the redirect server-side, you can append the referring URL as a query string param in your header() call, and then look for it on the target page and specify it as the referring URL.

I don't know how you are building your $golink variable, but basically you would add something along the lines of:

$golink .= "?ref=" . $_SERVER['HTTP_REFERER'];

Use a & instead of ? if there are already URL params, and the code above assumes using ref as the URL param, so use whatever var you want.

Then on your target pages, before your _trackPageview call, you would add

_gaq.push(['_setReferrerOverride', ref]);

ref would be a javascript variable with the value of the ref=xxx query string param. For some weird reason Javascript does not have a native way to grab URL param values, nor does GA provide an (exposed) solution. If you already have a solution on your pages for grabbing URL params (like something from a framework or a function you've already made) then use that. Otherwise it's pretty easy to find a javascript function that will do it for you.

There are a couple benefits to doing it this way:

  1. You don't have to worry about the visitor seeing an interstitial page.
  2. You don't have to worry about GA not getting a chance to fully load before redirect
  3. You can see the referrers tied directly to your landing pages, because with the interstitial page, you will always see that interstitial page as the referrer, and will have to look at referring url reports for the interstitial page.

这篇关于重定向HTTP引荐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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