Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work correctly with turbolinks #25

Closed
morgler opened this issue Feb 12, 2015 · 1 comment
Closed

Does not work correctly with turbolinks #25

morgler opened this issue Feb 12, 2015 · 1 comment

Comments

@morgler
Copy link

morgler commented Feb 12, 2015

I have a Rails 4.2 app with turbolinks. Google Analytics is set up through rack-tracker and I can see the correct code being rendered on the page. However, it only tracks page views or events, if I do a full page reload in the browser. If I simply click through my page via links, I do NOT get any page views or events. I guess this is due to turbolinks, which prevents a full page reload. Is there an option, to attach the page view and event reporting to the "page:change" event instead of a full page reload?

@morgler
Copy link
Author

morgler commented Feb 12, 2015

I just found another post of you with the hint to use "position: :body". This works with turbolinks :).

For everyone with this issue:
Add the "position" option to your tracker initialization:

config.middleware.use(Rack::Tracker) do
  handler :google_analytics, { tracker: 'UA-xxxxx', position: :body }
end

And be sure to use the master branch of the github repo directly, because this fix was not yet released:

gem 'rack-tracker', git: 'https://github.com/railslove/rack-tracker.git'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant