Question

I have a web app built upon Sinatra/Padrino that is up and running, but I want to make a small change to it in order to assist us with marketing it.

At the moment, when users type in the browser address bar www.mygreatapp.com they are taken to the app main page, which is probably a little confusing for a new user or prospect. Ideally, we would like it so that when they come to our home page from another site or a google search or manually typing in the URL, they are shown a separate landing page which explains the site in more detail, before they can then head to the actual home page.

Bear in mind that WITHIN the web app, there are links from deeper pages which redirect back to the home page, and we would like THOSE links to still go to the actual home page.

At the moment, the route handler for the home page is something like:

get '/' do
  render 'homepage'
end

What I essentially want it to be able to do is:

get '/' do
  if {{ This was called from within www.mygreatapp.com }}
    render 'homepage'
  else {{ This was called from externally or another site }}
    render 'landingpage'
  end
end

Is this possible? Is this even the best way to handle this sort of thing? Perhaps there is another way to accomplish this that I am missing?

Was it helpful?

Solution

Yes, it's possible and there are plenty of ways to do it. Personally, I'd give the landing page its own route, and place an eternal cookie (and maybe other stuff too in case cookies get wiped) on first visit that indicates someone has already been to the site. If they have the cookie, don't do anything. If they don't, they're new, redirect them to the landing page.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top