document.onload event and expect it to work (since this event will simply not be triggered more than once).
- Move the GoSquared tracker code into your site’s
- Add the following piece of CoffeeScript code:
The official GoSquared instructions will ask you to embed the tracker code at the very end of your
<body>. By moving it into the
<head> section of your site, we’re making sure it’ll only be loaded and initialized once within a Turbolinks session.
Turbolinks conveniently triggers a
page:change event every time a new page is loaded through it, which we’ll use to invoke the
GoSquared.DefaultTracker.TrackView function (which, as its name implies, will track the view with GoSquared, which is exactly what we want.)