railslove / rack-tracker

Tracking made easy: Don’t fool around with adding tracking and analytics partials to your app and concentrate on the things that matter.
https://www.railslove.com/open-source
MIT License
647 stars 121 forks source link

hotwired/turbo support and fixes issue with duplicate events in GTM #160

Closed wrozka closed 3 years ago

wrozka commented 3 years ago

This PR adds support for the new turbo-rails gem that supersedes turbolinks. It observes both turbo and turbolinks events.

Also, this PR fixes issue with multiple event listeners tracking stale events and duplicate page views. Since turbo (and turbolinks) are evaluating new scripts from the head element, it ends up registering a duplicate event listener any time a new event is pushed from the backend. This PR fixes that by generating a static script with the turbo event listener (it will be evaluated only once) and a dynamic script with backend events (its going be evaluated on every load if any events are present).

karthikkasturi commented 3 years ago

Any update when this feature will be available in rack-tracker?

DonSchado commented 3 years ago

@karthikkasturi thanks for the reminder.

@wrozka @karthikkasturi are you able to test this revision against a production setup?

wrozka commented 3 years ago

@DonSchado Yes, we're using this on production