K
K
kanonir082021-09-15 18:06:20
PHP
kanonir08, 2021-09-15 18:06:20

How to show text only for Yandex?

Hello. There is such a code

if (stripos($_SERVER['HTTP_REFERER'], '.yandex.') !== false) {
    echo "Show what I want";
}


This code works for Google (if you change '.yandex.' to '.google.'), but it doesn't work for Yandex. As far as I understand, due to the fact that Yandex transmits the Referrer in a different way. Tell me how to modify the code so that it displays the text only when you go to the page from Yandex?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Developer, 2021-09-15
@samodum

Most likely, the referrer is different, something like clickyandex.ru or yandexclick.ru
You can experiment and not be tied strictly to ".yandex.", remove the dot at the beginning or end of the line. But this is... There may be false positives from other Yandex-like site names.
It is better to check on your site by tracking the referrer by going to your site from Yandex

F
Fenix957, 2021-09-16
@Fenix957

Also note that Yandex sometimes sends users through Yandex.toloka like this
To check the quality of the site and then your code will not be displayed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question