0

I'm trying to show some content (introduction) to new visitors on some pages on website.com. I wish to "not bother" the user with it again if they've already seen it.

Let's say user comes in to website.com/cool-article I then show the user an introduction at the top and when the user then clicks website.com/useful-article-43 that page should now not contain the introduction. Or should I keep the introduction and just scroll down the user on the second page? Also I don't want to show the introduction if the user is a returning visitor. Website is built with PHP.

My concern is - which of these solutions would you chose to make sure SE bots don't go mad that the content varies? From what I've understood bots never bring along any referrer info.

Options:

1) Lookup $_SERVER['HTTP_REFERER'] ($httpReferer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null;)
If it's set to mywebsite.com or NULL
DO A or B

2) Store and check for a cookie that is set when the user visits the page. session_start(); if !$_SESSION['intro']
DO A or B
$_SESSION['intro']='introSeen';

3) Via JS/localStorage?
(Unnecessary loading of content?)

How would you do it?

(A&B)

A) don't load introduction to the page at all

  • +Less loading time when users that click a saved link arrive on the page and also for users.
  • -Risk of confusion
  • -The page doesn't look the same.

B) Scroll user down to the article, keep introduction on top.

  • +If user scrolls up the page looks the same as previous.
  • +Website always has the same content for all users as well as bots.
  • -Unnecessary loading of content
Alisso
  • 1,861
  • 1
  • 17
  • 32
  • Why not cookies/localStorage? That's how websites usually track returning visitors. It makes more sense to do this client-side. – howderek Oct 29 '13 at 14:11
  • I think I want to avoid downloading all the images & content for the introduction. But I guess perhaps if it's a returning visitor, that's cached anyway? Didn't think of that. – Alisso Oct 29 '13 at 14:15
  • @howderek why does it make more sense to do it clientside? – Alisso Oct 29 '13 at 14:17
  • 2
    Should be cached anyway. Console's "audits" tab is an easy way to make sure it actually is. Makes sense to do it client side because you're concerned about serving up the same content each time (bots). – Dagg Nabbit Oct 29 '13 at 14:18
  • That way the same content is always served. How big is the introduction? – howderek Oct 29 '13 at 14:22
  • 1
    If you want to avoid loading unessesary content you can have js create the introduction or load it with AJAX – howderek Oct 29 '13 at 14:27
  • If I load it with AJAX - bots won't see it? – Alisso Oct 29 '13 at 14:37
  • Why not inject it with Javascript only on the first occasion? – lonesomeday Oct 29 '13 at 14:37
  • 1
    I doubt bots would honor AJAX requests, but I suppose it's possible. Here's an example of creating an introduction on the first visit: http://jsfiddle.net/howderek/WYmkp/5/ – howderek Oct 29 '13 at 14:45

1 Answers1

1

The way I would go about solving this problem is by using client-side persistent storage, such as cookies or localStorage. That way the same content is always served, and the user's browser decides whether or not to show an introduction.

It's easy to implement a JavaScript solution that creates an introduction above the content if the user hasn't visited:

(function firstTime() {
    var introduction = '<div id="firstTime">Hello! This is your first time here!</div>';
    if (localStorage.visited === undefined) {
        document.body.innerHTML = introduction + document.body.innerHTML;
        localStorage.visited = true;
    }
})();

You can modify that to work in your case, or use cookies for better backwards compatibility.

See it in action: http://jsfiddle.net/howderek/WYmkp/5/

howderek
  • 2,224
  • 14
  • 23