MatteoGabriele / vue-gtag

Global Site Tag plugin for Vue (gtag.js)
https://matteo-gabriele.gitbook.io/vue-gtag/
MIT License
864 stars 64 forks source link

The events that appear on Google Analytics sometimes have wrong page. #175

Closed MaciejGorczyca closed 3 years ago

MaciejGorczyca commented 4 years ago

Description

The events that appear on Google Analytics sometimes have wrong page.

2020-08-15-15-32-11-755-1358x809-Analytics_-_Mozilla_Firefox

Expected behavior

All events should be on "/" page

Actual behavior

Events appear to be fired from multiple pages but only a single main page has any events.

Environment

Run this command in the project folder and fill in their results:

npm ls vue-gtag: -- vue-gtag@1.6.2 and retested on 1.8.0

  1. Operating system: Not system related, irrelevant I guess? Developed on Windows.
  2. Browser and version: Happens on Chrome, Firefox, Opera and Edge, so not browser related.

Reproducible Demo

VueGtag imported in main:

import VueGtag from "vue-gtag";

Vue.use(VueGtag, {
  config: { id: "UA-xxxxxx-1" }
})

Then used in code - button calls function undo:

undo: function () {
  // ...
  this.$gtag.event("undo_button")
},

If you need any further details or logs let me know. I found on web that:

A pageview hit must precede event hits in order for the event hits to include the page that they fire from. When event hits aren't preceded by a pageview, Google Analytics doesn't have the page for the event hits, so their page is (not set).

So perhaps the vue-gtag does not send pageviews sometimes. I noticed some wonky statistics on analytics page but don't know for sure.

To add a bit more, it seems my website had a small influx of new users and most of events seems to be fired from "how-to-use" page, maybe the tracking can't see that the page was changed or something. I don't really know. Something is wrong for sure but that's all I can tell.

MatteoGabriele commented 3 years ago

@MaciejGorczyca yeah I could reproduce the issue and also read about this

thanks for your feedback

MatteoGabriele commented 3 years ago

I'm sorry I forgot to update you. this bug has been most likely fixed while fixing another problem. just to remember that the plugin does not send page_view or screen_view events automatically unless you are using the built-in router auto-tracking feature, otherwise you have to manually hit the page_view yourself before sending an event.

let me know if there are any other feedback

cheers