0

I want to track where exactly is click from youtube video. U have tried with this code. But its return only "www.youtube.com/". I want to print this "https://www.youtube.com/watch?v=_bnur3gHJ0s"

<?
$whr = $_SERVER['HTTP_REFERER'];
print_r($whr);
?>
Dreamenemy
  • 95
  • 1
  • 9

2 Answers2

0

Because of HTTPS, you dont (always) get a referer. You could check with print_r($_SERVER) if there is something else, but don't rely on it too much.

A better solution would be to add a referer as get parameter, eg:
- example.com/somepage?ref=youtube_description
- example.com/somepage?ref=video&video=12345

Martijn
  • 15,791
  • 4
  • 36
  • 68
-1

Regex is probably your best method of choice. There's a post here that should benefit you.

PHP Regex to get youtube video ID?

Joshua N
  • 39
  • 5
  • In what way shape or form would regex solve this issue? The OP states that the referrer only contains `www.youtube.com`. That's all the OP gets. – M. Eriksson Jun 27 '18 at 09:31