swup / ga-plugin

A swup plugin for integrating Google Analytics 📈
https://swup.js.org/plugins/google-analytics-plugin
MIT License
2 stars 2 forks source link

Issue installing via NPM using 3.0.5 #27

Closed andresclua closed 1 year ago

andresclua commented 1 year ago

Hey guys, I was finishing my project ( started long time ago), and now I'm facing this issue. I can't install the plugin with 3.0.5 version.

Captura de pantalla 2023-08-02 a las 23 27 46

Any suggestion? I do not want to migrate to v4 yet. using node v19.8.1

Thanks in advance!

daun commented 1 year ago

The latest version of this plugin requires swup 4 to work. If you want to stay on swup 3, you can install the previous release:

npm install @swup/ga-plugin@^1.1.0
daun commented 1 year ago

@andresclua Sorry, I closed this one very quickly -- does specifically requesting version 1.1 of the plugin work for you?

andresclua commented 1 year ago

No worries @daun ! I fix it, and swap to v4 🥇

One thing that happened to me is that the documentation for analytics didn't work for me at first. On the website, it says:

// On sites using analytics.js

window.ga('set', 'title', document.title);
window.ga('set', 'page', window.location.pathname + window.location.search);
window.ga('send', 'pageview');

But, I ended up doing it this way:

gtag('set', 'title', document.title);
gtag('set', 'page', window.location.pathname + window.location.search);
gtag('send', 'pageview');

Should anything be changed in this case?

daun commented 1 year ago

Both are fine! The plugin checks for the existence of either ga or gtag and performs the tracking accordingly.