swup/ga-plugin

Selecting the tracking ID

Closed this issue · 1 comments

window.ga("set","title",n)

Was returning an undefined javascript error.

If you're initializing Google Analytics with google tag manager, this might work for you– it solved the problem for me:

var trackingID = window.ga.getAll()[0].get('name');
window.ga(trackingID + ".set","title",n);

Thanks for the tip. 👍 If anyone encounters GA problems, there is also Gtag plugin that should help. It probably depends mainly on how the GA is loaded in the first place, but it's good there are multiple options.