1

I'm currently having issues with a site which is not able to be indexed due to a cookie redirect function that's in place.

To summarize; when a user lands on the webpage for the first time they will be redirected to a splash page. Once they have visited this page once it will be stored in their cookies so that any subsequent visits mean they will be directed to the main homepage.

The code in place to achieve this is the following:

function check_for_redirect() {
    $days_to_expire = 30;

    if (!is_admin() && !isset($_COOKIE['already_visited'])) {
        setcookie('already_visited', true, time() + 86400 * $days_to_expire);
        wp_redirect('https://website.com/splash', 302);
        exit;
    }
}
add_action('init', 'check_for_redirect');

The code seems to work fine but I have noticed then when trying to submit my sitemaps.xml file to Google Search Console, it throws an error and seems unable to crawl the site.

Like wise when trying to post a link from the site onto Facebook, the splash page is getting referenced as though the Facebook crawlers are unable to get access to the links

Does anyone have any suggestions on how to get around these issues. I have looked into adding a line into the robots.txt file which would disallow Facebook crawlers from the /splash URL. But not sure if this is the best solution

Any advice would be much appreciated.

1 Answer 1

1

There is no way to make a cookie splash page work with SEO. Googlebot and other crawlers never send cookies. If you redirect any time there are no cookies, it makes your entire site uncrawlable.

If you decided to allow bots user agents to bypass this check then you would be cloaking and your site is likely to get penalized by Google and not show up in the search results.

What you are doing is fundamentally incompatible with how people use website from search. When people search for something, they expect to be able to click to a page with the information they are looking for. If you redirect them because they are a first time user, they will be very confused and frustrated. Almost all users would hit the back button and click on another site from the search results that is more user friendly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.