News for hackers. Stuff that matters.
Re:Show HN: Analytics.js – The analytics API you've always w... by alexdean on Wednesday December 12, 2012 @04:31PM (#4912581)
This is a cool idea for a project! The closest equivalent I'm aware of is Qubit OpenTag (https://github.com/QubitProducts/OpenTag).

I'm interested in adding SnowPlow support to this (https://github.com/snowplow/snowplow) - our tracking API is very similar to Google Analytics's.

We've just gone through the quite involved exercise of mapping SnowPlow to Google Tag Manager (http://snowplowanalytics.com/blog/2012/11/16/integrating-sno...) so I was a bit surprised in the code to see this mapping for GA events:

    track : function (event, properties) {
                window._gaq.push(['_trackEvent', 'All', event]);
            }
I'm a bit confused by this - how would I use analytics.js to pass through all the valid data that I can log in a GA event or indeed SnowPlow event - https://github.com/snowplow/snowplow/wiki/javascript-tracker...

I think you might be making the assumption that events consist of an event name plus arbitrary JSON envelope. This is a very MixPanelish view of the world - it doesn't really translate to Google Analytics, Piwik, SnowPlow, Omniture...

Re:Show HN: Analytics.js – The analytics API you've always w... by ianstormtaylor on Thursday December 13, 2012 @03:01AM (#4914821)
Really good points. I think there is definitely a way for the Mixpanel-esque API to map cleanly via a decided on spec to the GA-style API with 'category' and 'label'. We are thinking about how to solve this in the nicest way possible for the developer right now!
Re:Show HN: Analytics.js – The analytics API you've always w... by alexatkeplar on Thursday December 13, 2012 @03:19AM (#4914861)
It's going to be really hard to make a generic, non-lossy mapping in a static, stateless JS script. Have you looked at Google's dataLayer as an alternative yet? The setup guide for SnowPlow + dataLayer is here in case it's interesting: https://github.com/snowplow/snowplow/wiki/Integrating-javasc...

The dataLayer approach seems really sound to us - here's hoping other tag management solutions move to something similar (or standardise on Google's dataLayer API).

Re:Show HN: Analytics.js – The analytics API you've always w... by hayksaakian on Wednesday December 12, 2012 @03:34PM (#4912293)
It's ironic that HN can simultaneously abhor[1] and applaud[this] progressive invasions of privacy on the internet.

[1] http://news.ycombinator.com/item?id=4907609

Re:Show HN: Analytics.js – The analytics API you've always w... by jbail on Wednesday December 12, 2012 @03:42PM (#4912339)
Not really. There is a big difference between the posts you're referring to and the privacy concerns inherent in each.

The one underhandedly fills in information that the user hasn't explicitly given a site. That's abhorrent.

Another offers a solution for incorporating multiple analytics services into a website a sane way. That's worthy of applause.

They are completely different products/services serving completely different needs.

Re:Show HN: Analytics.js – The analytics API you've always w... by lazerwalker on Wednesday December 12, 2012 @03:44PM (#4912347)
I'd disagree that it's a natural progression to move from collecting anonymous (or at least pseudo-anonymous) use data from what your users actively do on your web site (which is very useful for measuring usage and making design improvements) to cross-referencing that with data your users did not give you for the explicit purpose of identifying them.
Re:Show HN: Analytics.js – The analytics API you've always w... by dchuk on Wednesday December 12, 2012 @04:28PM (#4912565)
There was a post on here a few weeks ago where people were specifically blasting KISSMetrics for using an Evercookie style tracking system, so I'd argue that HN hasn't come up with a coherent opinion of the moral implications of analytics and conversion tracking yet.
Re:Show HN: Analytics.js – The analytics API you've always w... by tomasien on Wednesday December 12, 2012 @11:18PM (#4914104)
STRONGLY disagree. The point of using analytics is to put metrics behind your decisions. You need your data to give you insights, but you need these insights to be generalized to larger demographics.

I.E. this type of person that is my potential customer doesn't convert on my landing page.

Personal targeting is a TOTALLY different thing. It's not about optimizing technology, it's about optimizing sales WITHOUT optimizing technology.

Re:Show HN: Analytics.js – The analytics API you've always w... by karolisd on Wednesday December 12, 2012 @03:40PM (#4912331)
It's not quite apples to apples, Google Analytics prohibits associating personal information with web analytics information.
Re:Show HN: Analytics.js – The analytics API you've always w... by jimmytucson on Wednesday December 12, 2012 @07:43PM (#4913445)
Sort of like we simultaneously censure and aspire to getting bought out by a larger software company?

Remember: it's one thing when it affects you as a user. It's another thing when it affects your users.

It just depends on which hat you're wearing.

Re:Show HN: Analytics.js – The analytics API you've always w... by bluesmoon on Wednesday December 12, 2012 @04:16PM (#4912501)
How does this script impact the performance of a site?

Specifically...

1. It includes code to load up various analytics tools even if you never use them. For example, if I only use GA and Mixpanel, do I really want to serve the bytes for all the other plugins to my users? Maybe it would be useful to only package the JavaScript that a certain site needs.

2. The script still blocks the onload event. See this post for a way around that: http://calendar.perfplanet.com/2012/the-non-blocking-script-...

3. How does having multiple analytics solutions on a page affect the load time of that page?

Lastly, I couldn't tell from the docs how to call methods before the script has finished loading. Is it similar to GA's method queue pattern?

Re:Show HN: Analytics.js – The analytics API you've always w... by Hovertruck on Wednesday December 12, 2012 @04:24PM (#4912541)
> It includes code to load up various analytics tools even if you never use them. For example, if I only use GA and Mixpanel, do I really want to serve the bytes for all the other plugins to my users? Maybe it would be useful to only package the JavaScript that a certain site needs.

It only has code that knows how to load each script, which isn't that much. So for example if you don't tell it to load chartbeat.js, it will never load chartbeat.js.

Regarding load time of pages, it's one thing we (Chartbeat) take really seriously, e.g. our default implementation waits until after onload before downloading anything and we keep our JS as light as possible. This script does, unfortunately, throw some of that out the window with it's implementation though. I'm working on my pull request already. :)

Re:Show HN: Analytics.js – The analytics API you've always w... by ianstormtaylor on Wednesday December 12, 2012 @04:30PM (#4912580)
Looking forward to it! Sorry to mess with your onload
Re:Show HN: Analytics.js – The analytics API you've always w... by ianstormtaylor on Wednesday December 12, 2012 @04:30PM (#4912578)
For the last question, all of the providers are initialized just like they would be normally, so GA's queue is setup already and it will just be routed the track calls.
Re:Show HN: Analytics.js – The analytics API you've always w... by sudonim on Wednesday December 12, 2012 @03:28PM (#4912268)
Happy to be supporting this project at http://customer.io . A lot of folks who use other tools want it to be easier to send the same information to everyone. Thanks guys for helping us all play nicer together.
Re:Show HN: Analytics.js – The analytics API you've always w... by mediascreen on Wednesday December 12, 2012 @04:24PM (#4912543)
Just remember that using email addresses as UserId string, like in the example, is against the Google Analytics terms of service.
Re:Show HN: Analytics.js – The analytics API you've always w... by ianstormtaylor on Wednesday December 12, 2012 @04:59PM (#4912711)
Don't worry, that identify call never gets sent to GA
Re:Show HN: Analytics.js – The analytics API you've always w... by stdbrouw on Wednesday December 12, 2012 @05:02PM (#4912723)
Hm, I seem to recall Google used to ban third-party wrappers in their Terms of Service, but I can't seem to find it in the ToS anymore – so either they've softened up or I have a faulty memory.
Re:Show HN: Analytics.js – The analytics API you've always w... by karolisd on Wednesday December 12, 2012 @03:04PM (#4912129)
For event tracking, how does

analytics.track('Purchased an Item', { price : 39.95, shippingMethod : '2-day' });

translate to Google Analytics?

_gaq.push(['...?

How many properties can you have?

Re:Show HN: Analytics.js – The analytics API you've always w... by ianstormtaylor on Wednesday December 12, 2012 @03:10PM (#4912159)
The Google Analytics provider doesn't send properties for events. The only thing the GA API providers that's even close is a "Label" which is just a string. The idea is to get as much from each provider as possible, so we just don't send properties when a provider can't use them.

Hope that helps!

Re:Show HN: Analytics.js – The analytics API you've always w... by troels on Wednesday December 12, 2012 @03:49PM (#4912373)
There's the ecommerce api though, which would apply to this specific case.

https://developers.google.com/analytics/devguides/collection...

Re:Show HN: Analytics.js – The analytics API you've always w... by ianstormtaylor on Wednesday December 12, 2012 @04:02PM (#4912433)
Ah yep that's a good point. Trouble is it doesn't apply to all cases, and has really strict requirements, but if it's a big enough need I could totally see a .price() method that hits GA's ecommerce API and then delegates to other providers's normal event API with properties. Wouldn't be a bad way to handle it.
Re:Show HN: Analytics.js – The analytics API you've always w... by rattray on Saturday December 15, 2012 @09:47PM (#4927135)
Maybe just pass the JSON object in as a string to the label? I personally don't think I'd mind reading "{'paymentAmount': 50, 'productColor': 'red'}". I haven't used Google Analytics for event tracking yet, though, so not sure what the UI around Labels is like.
Re:Show HN: Analytics.js – The analytics API you've always w... by tarr11 on Wednesday December 12, 2012 @03:50PM (#4912378)
I was hoping that this would be an open source version of Google Analytics.
Re:Show HN: Analytics.js – The analytics API you've always w... by smacktoward on Wednesday December 12, 2012 @04:06PM (#4912456)
You're looking for Piwik (http://piwik.org/), which is awesome.
Re:Show HN: Analytics.js – The analytics API you've always w... by arcatek on Wednesday December 12, 2012 @07:24PM (#4913361)
But ugly as hell. I mean, I would be willing to pay for getting them to work on the design.
Re:Show HN: Analytics.js – The analytics API you've always w... by neumann_alfred on Thursday December 13, 2012 @01:05AM (#4914501)
You can customize every last bit of it, it being open source. Feel free pay them or someone else to do just that. Nobody would claim it's the prettiest, but it's open source and self-hosted, surely that counts for something? The devil will always have the shinier bling, but it's also the devil.
Re:Show HN: Analytics.js – The analytics API you've always w... by alexatkeplar on Wednesday December 12, 2012 @04:47PM (#4912653)
We're more of an opensource complement to GA (rather than alternative), but for completeness: https://github.com/snowplow/snowplow
Re:Show HN: Analytics.js – The analytics API you've always w... by noinput on Wednesday December 12, 2012 @03:52PM (#4912393)
Re:Show HN: Analytics.js – The analytics API you've always w... by mikegirouard on Wednesday December 12, 2012 @04:27PM (#4912559)
Thanks for sharing this. I've use Piwik for a few years now, but this looks interesting too.
Re:Show HN: Analytics.js – The analytics API you've always w... by bluetidepro on Wednesday December 12, 2012 @03:20PM (#4912215)
This looks awesome! One thing would be nice on the demo/landing site is to maybe add screenshots of how your examples translate in Google Analytics or the others. Like karolisd mentioned in his comment, I would like to see how that stuff translates or what it looks like in the respective apps. Again, great work! :)
Re:Show HN: Analytics.js – The analytics API you've always w... by vtuulos on Wednesday December 12, 2012 @03:11PM (#4912163)
Great library! I know that a number of companies have created a wrapper of their own exactly for this purpose.

We could contribute integration to https://bitdeli.com for those who want to build their own analytics. Is it enough to add a new provider to availableProviders?

Re:Show HN: Analytics.js – The analytics API you've always w... by pkrein on Wednesday December 12, 2012 @03:21PM (#4912222)
Yep, feel free to just pull request to the analytics.js repo.
Re:Show HN: Analytics.js – The analytics API you've always w... by rossta on Thursday December 13, 2012 @05:31AM (#4915189)
Thanks for sharing. A useful improvement could be a build step that supplies only the metrics snippets that I want so I don't need to deliver to clients provider code I'll never use.
Re:Show HN: Analytics.js – The analytics API you've always w... by dudus on Wednesday December 12, 2012 @03:34PM (#4912291)
Google Analytics has a new api currently in beta that is also called analytics.js. This will be confusing.

https://developers.google.com/analytics/devguides/collection...

Re:Show HN: Analytics.js – The analytics API you've always w... by ry0ohki on Wednesday December 12, 2012 @04:20PM (#4912524)
Agreed. Please stick to the trend of a creative, whimsical, yet non-descriptive name, I recommend "SealFur.js".
Re:Show HN: Analytics.js – The analytics API you've always w... by pud on Wednesday December 12, 2012 @08:18PM (#4913594)
How about shortening it to Anal.js

(seriously, that would be a great name. and, ya know, in reference to being anal retentive. get your mind outta the gutter people.)

Re:Show HN: Analytics.js – The analytics API you've always w... by sgerrand on Wednesday December 12, 2012 @10:54PM (#4914048)
There's a typo on the README site that might indicate that they had similar ideas: `Google Analtyics`
Re:Show HN: Analytics.js – The analytics API you've always w... by munger on Thursday December 13, 2012 @03:00AM (#4914818)
AnalTrack.js
Re:Show HN: Analytics.js – The analytics API you've always w... by frozenport on Wednesday December 12, 2012 @10:59PM (#4914062)
I would like us to use a C++ like name mangaling convention like __1cGstrcpy6Fpcpkc_Analytics.js. In this way we will never confuse version numbers, with the added advantage to run several version concurrently. I recently purchased a CDN subscription for precisely this application.
Re:Show HN: Analytics.js – The analytics API you've always w... by joevandyk on Wednesday December 12, 2012 @05:56PM (#4912945)
Honestly, that makes it super easy to search for.
Re:Show HN: Analytics.js – The analytics API you've always w... by gopi on Friday December 14, 2012 @11:34AM (#4921732)
AnaGator.js - Short for Analytic Code Aggregator...also this name allows you to have a cute logo with a alligator :)
Re:Show HN: Analytics.js – The analytics API you've always w... by javajosh on Wednesday December 12, 2012 @05:13PM (#4912754)
How about a reference to the Mayan Apocalypse: doomsday.js
Re:Show HN: Analytics.js – The analytics API you've always w... by loceng on Thursday December 13, 2012 @09:45AM (#4915832)
I laughed out loud too far loudly for how awake I am.
Re:Show HN: Analytics.js – The analytics API you've always w... by rhizome on Wednesday December 12, 2012 @04:49PM (#4912661)
too many vowels.
Re:Show HN: Analytics.js – The analytics API you've always w... by Nagyman on Wednesday December 12, 2012 @03:49PM (#4912371)
There's also Google Tag Manager. It's not itself an analytics script, but it provides a clean way to separate tags from code (one tag to rule them all). In addition, it's dataLayer acts as an intermediate store which any tag can access via macros in order to use the shared data. The SEM folks can (almost) manage the tags themselves once some rules are prepared.

https://www.googletagmanager.com

Re:Show HN: Analytics.js – The analytics API you've always w... by randartie on Wednesday December 12, 2012 @06:05PM (#4912986)
This project will definitely have bad luck when it comes to google search results.
Re:Show HN: Analytics.js – The analytics API you've always w... by saurik on Thursday December 13, 2012 @03:03AM (#4914826)
When I saw this Show HN, I actually assumed it was an article about the new Google Analytics offering. (In retrospect, I should have realized that wouldn't make sense as a Show HN.)
Re:Show HN: Analytics.js – The analytics API you've always w... by Strshps1MoreTim on Thursday December 13, 2012 @03:30PM (#4917898)
Unless it was posted by norvig, or one of the other Google employes here.
Re:Show HN: Analytics.js – The analytics API you've always w... by dylanvee on Wednesday December 12, 2012 @05:26PM (#4912800)
function(i, s, o, g, r, a, m) {...}

How clever of them.

Re:Show HN: Analytics.js – The analytics API you've always w... by riffraff on Wednesday December 12, 2012 @08:05PM (#4913545)
fwiw, I was actually annoyed that the function does not take that many arguments, if I am not missing something.
Re:Show HN: Analytics.js – The analytics API you've always w... by tach on Wednesday December 12, 2012 @11:05PM (#4914078)
The extra arguments are used as identifiers within the function. It's a common trick to save a few bytes since you get function scoped vars without needing the "var" keyword.
Re:Show HN: Analytics.js – The analytics API you've always w... by riffraff on Thursday December 13, 2012 @05:03AM (#4915126)
yes but it's not needed in this case, they could have reused existing variables and since clarity is not a goal (given e.g. "s=document") it wouldn't be an issue.
Re:Show HN: Analytics.js – The analytics API you've always w... by tripzilch on Thursday December 13, 2012 @06:57PM (#4918838)
true, but if it aggregates multiple services, it makes more sense to have a generic name like "analytics", than for a singular service to have that name just because it's Google. still, you're right that it will probably be confusing.

edit: a reply below points out that it's hard to search for. that's actually a quite good reason why the author(s) might want to reconsider the name.

Re:Show HN: Analytics.js – The analytics API you've always w... by adamsfallen on Wednesday December 12, 2012 @04:14PM (#4912492)
I could have sworn this was the same thing. Oh god.
Re:Show HN: Analytics.js – The analytics API you've always w... by karolisd on Wednesday December 12, 2012 @03:38PM (#4912312)
Is that for the new Universal Analytics?
Re:Show HN: Analytics.js – The analytics API you've always w... by dudus on Wednesday December 12, 2012 @03:40PM (#4912325)
Yes this is also known as Universal Analytics and has several new features more processing on the server rather than on client side and less cookies. It's pretty awesome by the way.
Re:Show HN: Analytics.js – The analytics API you've always w... by dudus on Wednesday December 12, 2012 @03:43PM (#4912343)
At some point segmentio's analytics.js will have to be update to use Google's analytics.js when it goes public and deprecates Google's ga.js.
Re:Show HN: Analytics.js – The analytics API you've always w... by mguterl on Wednesday December 12, 2012 @03:45PM (#4912353)
I've been using analytical with our Rails backend which seems to achieve something similar:

https://github.com/jkrall/analytical

Re:Show HN: Analytics.js – The analytics API you've always w... by madoublet on Thursday December 13, 2012 @08:49AM (#4915632)
Really cool. But, I was kind of hoping the library would pull data from Google analytics to use for charting and stats within an app.
Re:Show HN: Analytics.js – The analytics API you've always w... by donohoe on Wednesday December 12, 2012 @04:19PM (#4912518)
If this covered Omniture I'd be over the moon...
Re:Show HN: Analytics.js – The analytics API you've always w... by spaetzel on Wednesday December 12, 2012 @03:20PM (#4912216)
Awesome, I was thinking of writing something like this, but you took the idea and made it much more powerful than i was planning.
Re:Show HN: Analytics.js – The analytics API you've always w... by Hovertruck on Wednesday December 12, 2012 @03:43PM (#4912341)
This is awesome! There's a few bugs in the Chartbeat implementation. Expect a pull request soon! :)
Re:Show HN: Analytics.js – The analytics API you've always w... by novaleaf on Thursday December 13, 2012 @12:26AM (#4914370)
Three words: Google Tag Manager.
Re:Show HN: Analytics.js – The analytics API you've always w... by davidradcliffe on Wednesday December 12, 2012 @03:28PM (#4912267)
I was just creating something like this for my project. This is great!!
Re:Show HN: Analytics.js – The analytics API you've always w... by karthik_ram on Wednesday December 12, 2012 @04:58PM (#4912703)
You didn't include gaug.es
Re:Show HN: Analytics.js – The analytics API you've always w... by benhamner on Wednesday December 12, 2012 @05:41PM (#4912874)
Web analytics just got meta