MatteoGabriele / vue-gtag

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

Google Analytics not working unsure of how to debug #119

Closed kevinhankens closed 4 years ago

kevinhankens commented 4 years ago

Description

Greetings! I believe that I have everything set up and configured correctly, however I am not seeing any tracking in Google Analytics and I have no idea how to debug this.

When loaded, I see that it renders the following:

<link href="https://www.googletagmanager.com" rel="preconnect">
<script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script>
<script async="" src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-90" charset="utf-8"></script>

The "Google Tag Assistant" Chrome add-on shows that the gtag.js is successfully loaded, however it does not record any Google Analytics and says "No hits were found in this recording."

I have attempted to fire events directly using:

> $0.__vue__.$gtag.pageview({ page_path: '/' })
> undefined

Here is how I am loading the gtag library:

import { bootstrap, setOptions } from 'vue-gtag'

export default {
  name: 'googleAnalytics',
  props: ['ga_id'],
  mounted: function () {
    if (this.ga_id !== '') {
      setOptions({
        config: { id: this.ga_id },
      })
      bootstrap().then(gtag => {
        this.$gtag.pageview({ page_path: '/' })
      })
    }
  },
}

Any advice would be greatly appreciated. Thanks kindly!

kevinhankens commented 4 years ago

Ah! It is working now. I'm not sure why, but there seemed to be a lag. Now new traffic is showing up immediately in the real time tracking.

Thanks so much for the hard work on this package!