How to get full referrer url in php
Asked Answered
A

1

6

I want to get full referrer url in PHP. For instance, if I come to mywebsite from a google search, $_SERVER['REFERER'] gives me only www.google.com, but I want smth like www.google.com/search?q=KEYWORD

Google Analytics provides that for many search engines. I need to get "/search?q=KEYWORD" query string.

Adamantine answered 1/2, 2013 at 20:44 Comment(9)
are you sure its $_SERVER['REFERER'] and not this => $_SERVER['HTTP_REFERER']Rough
Ahhh.. GoogleSkewer
/!\ Users using Google in HTTPS will not have any referrer.Balladeer
Duplicated? https://mcmap.net/q/53271/-get-the-full-url-in-phpNimocks
@JulienPalard google uses https on nearly most of there sites.Millisent
@joaobarbosa: possibly not duplicated!Stick
Why not testing your site from another domain (not google.com), just see if it prints full URL of the referrer, I tested on my PC, I can see full URL of the referrerStick
@Millisent That's why I warn halilenver, if he want to extract data from referrer, he will have some but not all expected (I actually use referrers as a source and we yet have a usable bunch of users from non-https google search)Balladeer
@JulienPalard is there anything that can be done to track google's query string when using https?Psychogenic
E
6

Put this in your script and have a look at it's content;

<pre>
<?php
var_dump($_SERVER);
?>
</pre>

This way you can find out which keys contain 'what'

Elijah answered 1/2, 2013 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.