89

As far as I'm aware, there is no public API exposure of a browser's default homepage/search provider. So how does Google know to display this? It only comes around when Google's not the default homepage / default search provider on my browser.

Google on-page popup: 'Get to Google faster. Switch your default search engine to Google.' Googe on-page popup: 'Come here often? Make Google your homepage.'

I can only assume they're inferring from numerous variables, such as the referrer. I wasn't able to successfully dig down into Google's compiled JavaScript. I'm not even sure if it's detected client-side or server-side.

I'm on Firefox 44, but I've seen these banners on Chrome, too.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Tennyson H
  • 1,705
  • 15
  • 28

3 Answers3

70

Simply there is no way to do that with JavaScript because the "default search/homepage" is a user's preference and you do not have access to that without user's permission because that would be a security/privacy issue.

What Google does at every user visit is show a promo ad with a close icon and a go button with instructions on how to set it as the default homepage. On click of any one of them, it creates 2 cookies so that next time it will check your cookies and make the promos disappear. Even when Google is your homepage and you clear your cookies then a banner is still there to promote Google as your homepage.

I have checked this with Firefox, not aware of Chrome.

JJJ
  • 32,902
  • 20
  • 89
  • 102
Shailendra Sharma
  • 6,976
  • 2
  • 28
  • 48
19

I don't know what Google does, exactly, but what I would do:

  • set the homepage URL with some special parameter and check it - 'http://www.example.com/#!homepage (prevents false negatives)
  • check for Referer field:
    • if it's NOT there, assume user has typed it in manually
    • if it's very similar for each user visit (and perhaps at what looks like the beginning of a browsing session - inferred via GA on eeevery page out there), assume user is coming here by always clicking through from somewhere
  • set a cookie, e.g. visitedHelpAboutHomePage when the user visits the "yes, show me" page (might prevent false negatives, but might also generate false positives)

Note that the "special parameter" does happen in the "searchbox-initiated search" scenario: there is a parameter sourceid which likely means "source of search."

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
  • 2
    An anchor `#homepage` is not submitted to the server though,but might be available to javascript. Also, I assume the homepage has no referer either, has it? – Hagen von Eitzen Dec 10 '15 at 21:36
  • Not bad, so you are trying to see if the user visit a website alot by typing in. Because you know, homepage only opens on a new-window, so most of the time, users type its address in, since it's not in the bookmarks in most cases. – Khaled.K Dec 16 '15 at 08:18
  • Hmm, distinguishing bookmark/homepage sounds hard (esp. as one is a special case of the other)... – Piskvor left the building Dec 16 '15 at 08:27
11

In my Firefox (v42), the "Come here often?" box appears even when I have Google set as the default search provider.

In Safari I get a box in the same location that says "A better way to browse the web: Get Google Chrome"

In Opera and Chrome I get no box at all, even if I change my default search provider to something other than Google.

So, I believe all they're doing is browser detection in the JavaScript, using the UserAgent object.

cutmancometh
  • 1,677
  • 3
  • 20
  • 28
  • 1
    I guess it could be a based purely off the UA, but one would hopefully expect Goog not to push out millions of false-positive marketing banners a day? I do realize the irony in this comment. – Tennyson H Dec 10 '15 at 07:30
  • 3
    Being the search provider is totally different than being your default home page. – Elin Dec 10 '15 at 10:17