kangguru / rack-google-analytics

Simple Rack middleware for implementing google analytics tracking in your Ruby-Rack based project. Supports synchronous and asynchronous insertion and configurable load options
MIT License
257 stars 53 forks source link

TurboLinks #50

Closed fascox closed 9 years ago

fascox commented 9 years ago

have issue with this gem and turbo links. Realtime page view are not tracked following links on website. It will track only on page refresh. It si compatible with turbo links enabled?

Rails 4.1

kangguru commented 9 years ago

no, this is not supported. please migrate to Rack::Tracker where i just made the needed changes to make it work with turbolinks. (please checkout master, its not released yet)

config.middleware.use Rack::Tracker do
    handler Rack::Tracker::GoogleAnalytics, tracker: 'UA-YYYZZZZ-1', position: :body
end

you need to specify the position - option, so the GA snippit isn't rendered in the head, what would be the default.

kelso commented 9 years ago

@kangguru Many thanks for pointing us to Rack::Tracker, it works with turbolinks! Just for the info, let me update your snippet according to the current Rack::Tracker docs:

config.middleware.use(Rack::Tracker) do
  handler :google_analytics, { tracker: 'UA-YYYZZZZ-1', position: :body }
end
kangguru commented 9 years ago

@kelso cool, glad to here that!

both snippits should (hopefully) do the same, although, the one you posted is more elegant.

but, there is actually an issue with turbolinks railslove/rack-tracker#26 if you could check that out, i'd be very grateful, as i don't have a turbolinks app at hand right now.