swup
Version:
Animated page transitions with css.
22 lines (19 loc) • 697 B
JavaScript
module.exports = {
name: 'swupGaPlugin',
options: { runScripts: false },
exec: function exec(options, swup) {
document.addEventListener('swup:contentReplaced', function () {
if (typeof window.ga === 'function') {
var title = document.title;
var url = window.location.pathname + window.location.search;
window.ga('set', 'title', title);
window.ga('set', 'page', url);
window.ga('send', 'pageview');
swup.log('GA pageview (url \'' + url + '\').');
} else {
console.warn('GA is not loaded.');
}
});
}
};
;