Damn, you beat me to it. After I saw the original visitor.js was a paid service (which blew my mind), I started hacking together the JS implementations of most of the functionality I had laying around already.
Your best bet is html5 geolocation + modernizr.js + a shim. Browsers that support html5 geolocation will return highly accurate results while those that don't support it will fall back to calling the google maps api (ip to geo).
The opt-in button is messy but results are very precise and reliable. Some use cases warrant it, some do not. Maxmind claims 79% accuracy on a city level: is the google api worse? All other things being equal I would be inclined to pick the one that didn't require me to frequently install binary patches or update a database.
I added in support for http://ipinfodb.com/ (see bottom of README) which might be better than Google's api, although you need to register for an API key.
You might want to give that a shot.
I don't think there are any ethical issues here. The paid service is doing something that was mostly, if not completely, available in other open source projects such as piwik and OWA in the first place. It's very educational to look at the differences in the way codejoust implemented his javascript vs. these other projects, and very convenient that you don't have to dig through a gigantor open source code base to do it.
I don't understand the pricing model behind visitorjs, and we had to implement a similar solution at my company. But the fact is - they created something and shared it here. If you think you can do a better job at it - fine, but why haven't you done it before, or at the very least named it differently. I don't mean to exaggerate, but it just doesn't feel ethical to me.
What are the ethical concerns about using this and storing the data? If I wanted to use this on my site, should I let visitors know, or is this data fair game to store? I rather not use the location data (or any of it) if there could be an issue.
Since websites need a privacy policy if they have users in California anyway, you might as well put your use of the data into it.
You should always tell your users what data you gather and how you use it. If you only let the data stay in the browser and never send it to the server then tell them.
2: None of this is being stored, beyond a cookie. Of course, you can call back to the server with that data, but the server has your IP address, which is where the location data came from.
No. And the recently-posted paid visitor.js site does have a few advantages, most being that this is using pure javascript, while they have the server side doing most of the heavy lifting.
In that case, this implementation really should have a different name. It's confusing to have two competing implementations share the same name, and it may be a trademark violation.
"visitor.js" isn't distinct in the field, particularly as it's descriptive and of a common form, I'd warrant it's not novel either.
That doesn't mean that you wouldn't be sued for using it just that any sane TM office shouldn't allow it to be registered and that a sane IP judge should dismiss a case brought against it's use as passing off. The law isn't sane of course ....
I think it's reasonable to use the same name if the scope is largely co-terminous.
It's because the scope is co-terminous that having different names is so important. IANAL, but trademarks don't have to be distinct or novel to be legitimate. They are allowed to be descriptive (like Windows or iPhone).
The fork of OpenOffice.org was named LibreOffice, because it would be unfair to name a competing product with the same name. I'm glad the author of this library has decided to do the same.
First up, "iphone" is definitely not descriptive, it's abstract, a made up word. "touchPhone" would be descriptive. "Windows", well ... it's a generic term now but at the time, despite it being to some extent descriptive of a WIMP system it was arguably a distinctive term for an OS (but I'm surprised it was allowed).
OpenOffice.org is interesting because they previously named the project "Open Office" and suffered trademark problems and had to be very careful to use the full name of the project. But had the former project been called "Computer Office Suite" then trademark issues wouldn't have arisen because that's not a distinctive mark and so couldn't be protected, it's descriptive anyone selling such software could use that description.
It's not unfair to use an identical descriptive name for things that serve the same function - for example Microsoft and Apple both sell something that they use the term "Operating System" to describe. OS is a descriptve term that is expected to be used in the field and so can't be a trademark, it doesn't serve to indicate origin.
I'd argue that visitor.js is an expected name for a piece javascript that logs visitors in some way, it's not distinctive of origin. Moreover it is descriptive of the function of the code. Kinda like having an ad loader that's called ads.js.
FWIW, and I've not been paying too much attention (!), only one of the pieces of code labelled visitor.js appears to be a product.
I'm super impressed you turned this out so quickly. I think that really sums up the spirit in the HN community...
When you look at something that seems overpriced (or wrongly-priced) and you say "hey, I bet I could do this"
I still see value in potentially paying for a service like this when it's a big enough pain-point. But I really think they'd have had more traction with a open-source-to-paid model, where anyone can use the client-side code for free, but the extra stats and support provided are worth paying for.
Having a "first session" and "current session" exposes very interesting functionality. It suddenly provides a quick way to keep track of what search keywords they used to get to the site, and could be later linked to an account if later created.
Developers should have learned by now not rely on Google for anything. Once all competing paid services (just like visitor.js) get driven out of business by Google's free service, you can count on Google doing the ol' bait and switch, by taking down the free API, erecting a paywall leaving themselves with a monopoly.
did you see vistor.js hit HN and rewrite it in a few hours? or were you working on this in isolation and when you saw it on HN decided it was the perfect time to ship?
I thought about doing that. I've used a lot of coffeescript in the past, but I just didn't see it being a big advantage here.
The biggest issue with using CoffeeScript here is that I wanted control over the syntax as I wanted to have less code.
CoffeeScript (generated) really creates more code than what it's worth.
People who understand it's not a JS file, it's a generated JS file containing data the server of that file had to look up and process to create the JS.