jkrall / analytical Goto Github PK
View Code? Open in Web Editor NEWGem for managing multiple analytics services in your rails app.
License: MIT License
Gem for managing multiple analytics services in your rails app.
License: MIT License
In lib/analytical/api.rb there is a check for Rails 3.1 like so: if ::Rails::VERSION =~ /^3\.1/
The same Rails 3.1 codepath should probably be run for all versions > 3.1, but the check as it is will only work with 3.1.x. So Rails 3.2 executes the old path and raises a bunch of deprecation warnings.
In my view specs, templates that included calls to analytical.event
were causing exceptions. It turns out this was because ActionView::TestCase::TestController
wasn't inheriting the call to analytical
that I put in my ApplicationController
. The easiest fix I found was adding this to my spec_helper.rb
:
# Give TestController an empty list of analytical modules
ActionView::TestCase::TestController.class_eval do
self.analytical_options = {:modules => []}
end
Seems like it might be nice for Analytical to provide RSpec integration so that this doesn't have to be debugged and then added by hand. Thanks!
Hi,
I created a Wiki Page to help KissMetrics users migrate to Analytical. There are a couple things I still want to add, but I do think it's useful as is.
https://github.com/gyarra/analytical/wiki/KissMetrics
I'd like to add a page like this for every package I'm familiar with.
If you enable wiki pages for the project I can add it directly.
Thanks!
Gabe
It would be nice if analytical could be used from mailers and models in the same way as from controllers and views, too.
Update:
OK, after studying the code of the analytical gem I realized that all the tracking commands are called via javascript on the client side. Even for tracking commands in the controllers...
But even so I feel that it would be possible to make it work for models and mailer by using a library like http_party and a queue to make calls from the server side.
Would be interesting to know what others think about this....
Since we use HAML, I added the line below to the beginning of my header but it causes an "undefined merge issue".
= raw analytical.head_prepend_javascript
Rails 3.0.9, analytical 3.0.6.
ActionView::Template::Error (Missing partial /home/dblock/.rvm/gems/ruby-1.9.2-p180/gems/analytical-3.0.6/app/views/application/analytical_javascript.html with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml, :haml], :formats=>[:html], :locale=>[:en, :en]} in view paths "/home/dblock/source/gravity/dblock/app/views", "/home/dblock/source/gravity/dblock/vendor/plugins/country_select/app/views", "/home/dblock/.rvm/gems/ruby-1.9.2-p180/gems/analytical-3.0.6/app/views", "/home/dblock/.rvm/gems/ruby-1.9.2-p180/gems/devise_invitable-0.5.2/app/views", "/home/dblock/.rvm/gems/ruby-1.9.2-p180/gems/devise-1.4.2/app/views", "/home/dblock/.rvm/gems/ruby-1.9.2-p180/gems/kaminari-0.12.4/app/views"):
9: = include_stylesheets :ipad if ipad_device?
10: = include_stylesheets :edit_artwork if current_user.has_authorization_to?(:update, Artwork)
11:
12: = raw analytical.head_append_javascript
13:
14: %body
15: = raw analytical.body_prepend_javascript
app/views/layouts/client/main.html.haml:12:in `_app_views_layouts_client_main_html_haml__428043036_126237760__535360229'
app/controllers/application_controller.rb:32:in `block (3 levels) in <class:ApplicationController>'
app/controllers/application_controller.rb:31:in `block in <class:ApplicationController>'`
Is there any reason this gem has a dependency on Rails 3.0.9? Does this mean if I'm running Rails 3.2.7 installing this gem will also install Rails 3.0.9?
Can I dynamically create new Google Analytics accounts for new websites through API?
I have a fair idea of how to do this thanks to iconara's snogmetrics (http://github.com/iconara/snogmetrics), but I was curious what you had to say on this topic. I'd really like to be able to call "analytical.event('foo')" in a controller that ends up redirecting without losing that event or having to use the server-side implementation (blegh!).
Thoughts?
I was wondering if there could be a new rubygem release since there have been a good amount of changes since the last release. I'm fine using the commit sha for now, but it would be handy.
Thanks!
I notice it being used much more frequently lately, and it has some pretty good reviews. Might be worth adding to Analytical.
I'm really late to the game on this one, but I've just now realized that :development_modules does nothing since version 2.11.0. As a result, I've been storing crap data in my various analytics providers for over a year. Naturally, this is problematic and broke pretty heavily with the backwards compatibility note in the README.
I tested Analytical for KissMetrics implementation in my project, which
The Issue is: Events are triggered from controllers, but there is need to refresh the page, to reload javascript code in head tags after calling analytical.event
method.
When websites uses page.on 'load'
or page.on 'pageshow'
events, kissmetrics doesn't trigger any event.
It should be a way to reload script after Turbolinks/jQuery Mobile events.
It'd be very helpful if there were a changelog indicating what's different from release-to-release. I'm looking to upgrade an app from Rails 2.3 -> 3.0 and I can't tell which version of analytical I should target. The latest doesn't work with Rails 3 and appears not have for for several versions now. Beyond that, it'd help let me know whether a new release is worth upgrading to or not.
Starting with analytical 2.7, there are a lot more dependencies listed in the gemspec. My guess is these were added by one of the new modules. In any event, analytical now only works with Rails 2.x, for x >= 3 and will not load up in Rails 3.
def create
<do stuff>
if something.save
analytical.track('It Saved!')
redirect_to 'somewhere/else'
else
...
end
end
The track seems to get discarded/lost in this case. Is that a known issue, unknown issue, or a feature?
My key is like: 12345678
The crazy egg module does this:
code_url = "#{options[:key][0,4]}/#{options[:key][4,4]}"
which would work if "key" is a String, but YAML reads the key as a Fixnum and throws:
wrong number of arguments (2 for 1)
analytical-2.6.0/lib/analytical/modules/crazy_egg.rb:13:in `[]'
calling "to_s" before the indexing should fix. There are no specs for this module or I would have just submitted a patch. Instead I hacked a workaround by appending "xxx" to my key to force it to be a String.
Hi!
I'm using analytical in my application but I have to update the google analytics tracking code (https://support.google.com/analytics/answer/2444872?hl=en&utm_id=ad).
How can I do that?
Thanks!
It's been a year since the last gem version, so maybe it's prudent. That is unless everyone else uses the github version anyway, in which case nevermind ๐ฑ
Added to config/analytical.yml:
production:
development:
kissmetrics:
key: XXXXXXXX
mixpanel:
key: XXXXXXXX
And added the following to my controller:
analytical :use_session_store => true
Added the following to my site's layout, in <head>:
<%= raw analytical.head_prepend_javascript %>
I followed the README, any idea what I might be doing wrong?
The list of services in the README is missing mixpanel.
https://github.com/jkrall/analytical/tree/master/lib/analytical/modules
So, you guys are looking for one right?
I can help. I currently maintain carrierwave and minimagick and I'm in a project that uses analytical.
Would be nice to add MixPanel support as well.
Hi,
I have installed the gem
and I have been trying to call the methods .identify and .track but get undefined method `merge' for nil:NilClass.
In my config/analytical.yml I have the following:
production:
kiss_metrics:
js_url_key: '//doug1izaerwt3.cloudfront.net/MYKEY.js'
I have been following https://github.com/gyarra/analytical/wiki/KissMetrics but I am only on step 2.
I am using rails 4.0.1.
Anyone able to provide me some direction or point out where I am going wrong? Do let me know if you need more information.
Any plans to implement it?
Specifically, you can't do: $H(#{data.to_json}).toJSON()
This is going way back, but in 2.11.0 the declarative configuration options for :modules and :development_modules were replaced by an environment-based setup in the analytical.yml file. A consequence of this is it's way too hard to log to the console. The console is one of the best things about analytical because I can see what's happening as things get processed. The reason for the difficulty is two-fold:
development: console:
But something like this will:
development: console: garbage: true
This is neither documented nor expected. An explicit configuration line might make more sense, but may break with the backwards-compatible file processor.
It seems unlikely that the change in 2.11 will be rolled back now, as it's been in place for the entire life of the 3.x series. So, feedback on how to deal with this would be appreciated. I'm happy to help out any way I can.
Hi,
First, thanks for the gem. It's pretty awesome.
I'm using KissMetrics and would like to call TrackSubmit. I don't see a way to do that with the current code base. It seems pretty easy to add. If I add TrackSubmit to KissMetrics, and perhaps the corollary track_forms to MixPanel, would you accept the pull request?
Thanks,
Gabe
We had been using the analytical gem circa version 2 and recently upgraded to 3.0.12. It appears that the view helper wasn't loading correctly, giving the following error:
undefined local variable or method 'analytical' for #<#<Class:0x10a261b18>:0x10a251560>
Adding helper_method :analytical
to our application_controller.rb fixed this issue. We are on rails 3.1.3.
Hey,
I discovered a really annoying bug when you create the analytical.yml file exactly according to the readme, like this:
production:
google:
key: UA-5555555-5
clicky:
key: 55555
This will give the error:
uninitialized constant Analytical::Modules::Production
or
uninitialized constant Analytical::Modules::Kissmetrics
when calling the "analytical" helper from a controller or a view.
The error is resolved when removing the space before the API-keys, so the file looks like this:
production:
google:
key:UA-5555555-5
clicky:
key:55555
This is a very annoying bug, since it's almost impossible to detect.
I hope you're able to fix it soon.
PS: I would suggest to update the Readme in the meanwhile, so more people don't unnecessarily run into it by following the setup procedure there.
Cheers.
After following the Readme and configuring Clicky provider only, my data collection is empty.
Do you have suggestions to troubleshoot this ?
This is my HTML generated by HAML on Rails 3.2.2 : https://gist.github.com/2135704
HI first thanks for this great gem. I noticed that the google_universal support is only available on the master branch and not in any of the release branches. Is there an ETA when it will be officially released. Also, the event tracking api as implemented doesn't fully match google's spec.
https://developers.google.com/analytics/devguides/collection/analyticsjs/events
The current implementation hard codes the category as "Event", and doesn't support the last number parameter. I'm happy to provide a pull request with the desired enhancements but just wanted to check to make sure I didn't miss anything.
Hi,
I noticed some differences between the code in the gem and the code on Github. It appears that the gem code is more current, although both say they are version 3.0.12. I'm happy to merge in code from the gem that seems more up to date.
mpmetrics
. In the source it's referenced mixpanel
- not actually the JS lib name.3 differences
2 differences
3 differences.
Just say the word and I'm happy to jump in.
Thanks!
Gabe
Just a quick idea, which I may or may not have time to hack on at some point. It would be really neat if I could avoid having to add all the [head|body]_[prepend|append]_javascript
calls in my layout by having a Rack middleware which injects them as the response goes out.
I've only managed to test on Rails 3.2, but it looks like SessionCommandStore has been broken since 9b0833e was introduced. The core problem is the config file is now loaded as a HashWithIndifferentAccess, rather than as a simple hash. HashWithIndifferentAccess ensures any hash values are also types of HashWithIndifferentAccess. In order to do so, it must make a new copy of the value. In this case, the value is the session, which is a hash. Creating a new session with indifferent access creates a new hash that is no longer associated with the session, so all modifications are now on an in-memory copy.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.