6 ms·
Show HN: Analytics.js – The analytics API you've always wanted
- mguterl 14y agoI've been using analytical with our Rails backend which seems to achieve something similar: https://github.com/jkrall/analytical https://github.com/jkrall/analytical
- karolisd 14y agoFor 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?
- ianstormtaylor 14y agoThe 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!
- troels 14y agoThere's the ecommerce api though, which would apply to this specific case. https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce https://developers.google.com/analytics/devguides/collection...
- ianstormtaylor 14y agoAh 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.
- rattray 14y agoMaybe 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.
- vtuulos 14y agoGreat 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 https://bitdeli.com for those who want to build their own analytics. Is it enough to add a new provider to availableProviders?
- pkrein 14y agoYep, feel free to just pull request to the analytics.js repo.
- bluetidepro 14y agoThis 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! :)
- spaetzel 14y agoAwesome, I was thinking of writing something like this, but you took the idea and made it much more powerful than i was planning.
- davidradcliffe 14y agoI was just creating something like this for my project. This is great!!
- sudonim 14y agoHappy to be supporting this project at http://customer.io 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.
- dudus 14y agoGoogle 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/analyticsjs/ https://developers.google.com/analytics/devguides/collection...
- karolisd 14y agoIs that for the new Universal Analytics?
- dudus 14y agoYes 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.
- dudus 14y agoAt 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.
- Nagyman 14y agoThere'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 https://www.googletagmanager.com
- numbchuckskills 14y agoI was thinking the same thing
- adamsfallen 14y agoI could have sworn this was the same thing. Oh god.
- hayksaakian 14y agoIt'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 http://news.ycombinator.com/item?id=4907609
- lazerwalker 14y agoI'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.
- dchuk 14y agoThere 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.
- tomasien 14y agoSTRONGLY 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.
- karolisd 14y agoIt's not quite apples to apples, Google Analytics prohibits associating personal information with web analytics information.
- jbail 14y agoNot 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.
- deleted 14y ago[deleted]
- Hovertruck 14y agoThis is awesome! There's a few bugs in the Chartbeat implementation. Expect a pull request soon! :)
- tarr11 14y agoI was hoping that this would be an open source version of Google Analytics.
- noinput 14y agothere is always: http://www.openwebanalytics.com/ http://www.openwebanalytics.com/
- mikegirouard 14y agoThanks for sharing this. I've use Piwik for a few years now, but this looks interesting too.
- smacktoward 14y agoYou're looking for Piwik (http://piwik.org/ http://piwik.org/), which is awesome.
- arcatek 14y agoBut ugly as hell. I mean, I would be willing to pay for getting them to work on the design.
- neumann_alfred 14y agoYou 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.
- alexatkeplar 14y agoWe're more of an opensource complement to GA (rather than alternative), but for completeness: https://github.com/snowplow/snowplow https://github.com/snowplow/snowplow
- bluesmoon 14y agoHow 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-loader-pattern/ 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?
- Hovertruck 14y ago> 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. :)
- ianstormtaylor 14y agoLooking forward to it! Sorry to mess with your onload
- ianstormtaylor 14y agoFor 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.
- donohoe 14y agoIf this covered Omniture I'd be over the moon...
- mediascreen 14y agoJust remember that using email addresses as UserId string, like in the example, is against the Google Analytics terms of service.
- ianstormtaylor 14y agoDon't worry, that identify call never gets sent to GA
- alexdean 14y agoThis is a cool idea for a project! The closest equivalent I'm aware of is Qubit OpenTag (https://github.com/QubitProducts/OpenTag https://github.com/QubitProducts/OpenTag). I'm interested in adding SnowPlow support to this (https://github.com/snowplow/snowplow 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-snowplow-with-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#wiki-events 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...
- ianstormtaylor 14y agoReally 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!
- alexatkeplar 14y agoIt'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-javascript-tags-with-Google-Tag-Manager 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).
- karthik_ram 14y agoYou didn't include gaug.es
- stdbrouw 14y agoHm, 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.
- benhamner 14y agoWeb analytics just got meta
- novaleaf 14y agoThree words: Google Tag Manager.
- rossta 14y agoThanks 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.
- madoublet 14y agoReally cool. But, I was kind of hoping the library would pull data from Google analytics to use for charting and stats within an app.