utnalove
09-30-2011, 05:58 PM
If I have the site www.mysite.com with the following htaccess:
RewriteRule ^gotocompanysite\.php$ http://www.companysite.com/ [R=301,L]
and my visitors click on www.mysite.com/gotocompanysite.php they are redirected to companysite.com
The question is:
does companysite see in google Analytics that the referrer is mysite.com or does it consider as direct?
I believe an address that issues a 301 redirect will not appear in the HTTP_REFERER field. The origin of the request to gotocompanysite.php will.
Inigoesdr
09-30-2011, 09:22 PM
301 redirects should preserve the HTTP_REFERER of the original request, but you can easily test this by going through the redirect and putting this in your address bar:
javascript:alert(document.referrer)
Or use Firebug/JavaScript Console if your browser supports it.
utnalove
09-30-2011, 09:44 PM
companysite.com awards me for the visits coming from mysite.com
I have many fans in Facebook. If I publish the www.mysite.com/gotocompanysite.php link, then they are redirected to companysite.com from my page.
However it looks like the original referrer is kept: here is what I see after I am redirected to companysite.com:
This link is shown as referrer:
http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.mysite.com%2Fgotocompanysite.php&h=TAQA_TFfHAQDaBghGWPhNCZ52WVNMYC3uyHLJB7Rj9fT3dA
What does it mean? Will companysite.com see that the visits came from facebook, or they will see they came from mysite.com?
What can I do in order to make mysite.com the referrer?
Thanks
Inigoesdr
09-30-2011, 10:04 PM
What does it mean? Will companysite.com see that the visits came from facebook, or they will see they came from mysite.com?
What can I do in order to make mysite.com the referrer?
Thanks
Yes, that's what it means.
You can manually specify the referrer for GA. Just append a value to the destination URL so you know where it came from like: companysite.com?internal=1
Then on your companysite page you can conditionally add the referrer setting using server-side code like PHP, or even client-side with JS. Here is how you would do it with PHP:
<script type="text/javascript">
var _gaq = _gaq || [];
// set your account
<?php
if(isset($_GET['internal']) && $_GET['internal'] == 1)
{
?>
_gaq.push(['_setReferrerOverride', 'mysite.com']);
<?php
}
?>
_gaq.push(['_trackPageview']);
// etc..
</script>
utnalove
09-30-2011, 10:12 PM
Thanks Inigoesdr, however the companysite.com is not mine and I do not have any influence on that... I cannot change their GA or add JS to their site.
The only thing I can do is to work on mysite.com... there I can change .htaccess, html, php, etc.
This action should be invisible to companysite.com - they need to think that all the visits they are receiving are coming from mysite.com - in reallity they:
--- come from facebook to my site, and then automatically redirected to companysite.com
I could add the companysite.com directly on facebook, but I want them to see that they are coming from mysite.com
Inigoesdr
09-30-2011, 10:34 PM
How about using the utm* vars in your redirect?
http://companyname.com/?utm_source=mysite.com&utm_medium=cpc
utnalove
09-30-2011, 10:41 PM
maybe, I don't know how it works... will companysite.com see it came from facebook still or from mysite.com?
utnalove
09-30-2011, 10:44 PM
just tried:
RewriteRule ^gotocompanysite\.php$ http://www.companysite.com/?utm_source=mysite.com&utm_medium=cpc [R=301,L]
The FireFox RefControl plugin says that the referrer is:
http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.mysite.com%2Fgotocompanysite.php&h=TAQA_TFfHAQDaBghGWPhNCZ52WVNMYC3uyHLJB7Rj9fT3dA
Inigoesdr
09-30-2011, 10:52 PM
It doesn't change the referrer, it just lets GA know where you came from. See the docs (http://www.google.com/support/analyticshelp/bin/answer.py?answer=1033863) for more info.
utnalove
10-01-2011, 07:56 AM
Is it enough to put this in the .htaccess in order for companysite.com GA see that it came from mysite.com?
RewriteRule ^gotocompanysite\.php$ http://www.companysite.com/?utm_source=mysite.com&utm_medium=cpc [R=301,L]
or that Javascript is a must?