Analytics ready!

In the option object of the plugin there’s a callback function available that fires when analytics.js or analytics_debug.js is loaded

always remember that the debug version is more heavy than the production one and might take more to load

  1. import VueAnalytics from 'vue-analytics'
  2. Vue.use(VueAnalytics, {
  3. beforeFirstHit () {
  4. // this is right after the tracker and before every other hit to Google Analytics
  5. },
  6. ready () {
  7. // here Google Analytics is ready to track!
  8. }
  9. })

It is also possible to use the onAnalyticsReady method, which returns a promise.

  1. import VueAnalytics, { onAnalyticsReady } from 'vue-analytics'
  2. Vue.use(VueAnalytics, { ... })
  3. const App = new Vue({ ... })
  4. onAnalyticsReady().then(() => {
  5. App.$mount('#app')
  6. })