question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to send the first view? [SSR][bootstrap=false]

See original GitHub issue

Hi @MatteoGabriele ,

I’m struggling to send the first view when reaching my website.

All following $router.push will be catched by vue-gtag (I can see them inside GTM Debug Chrome extension), but the first one is not. I’m wondering if it could come from the fact I use server-side rendering, however the script seems loaded when I call bootstrap(): image

I also tried to set bootstrap: true so there is an immediate activation, but that’s the same.

I’m not using Nuxt.js but the “raw” Vue SSR (often with entry-client.js and entry-server.js), if you have any idea what could be the cause, it would be great 👍

Thank you,

EDIT: It seems when doing

      params: {
        send_page_view: true,
      },

the library catches the first one too. I knew it was in the docs but when trying earlier it was not working hmmm… Don’t know what could have be in conflict (cache or other?). It catches in a different format (http://localhost/home instead of /home for the following page changes), but that’s maybe the normal behavior.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
TitanFightercommented, Jan 16, 2021

This works as a workaround for the first view:

bootstrap().then(() => {
    this.$gtag.pageview({
        page_path: this.$route.path
    })
})
1reaction
kieranscommented, Dec 18, 2020

I’m having a related problem. The host page for my app (including the <script> include for the Gtags library) is rendered serverside. I have a window.onload event handler that tells my Vue app to bootstrap the analytics module which in turn calls bootstrap in vue-gtag.

I’ve noticed that even with send_page_view: true in my params the first view event isn’t being sent to GA. I’ve checked the dataLayer object and I can’t see any network traffic.

Debugging it with some console.log statements in a copy of vue-gtag@1.10.0 I can see that when the Routers onReady handler is invoked the value of current is undefined. Thus no data can be sent.

I don’t know if it’s a fault of the Vue Router (vue@^2.6.10, vue-router@^3.1.6) or if that’s expected behaviour. Is there a way to check for a current route for the base where vue-gtags is bootstrapped post app initialisation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Return back to first slide when carousel reaches last
You can achieve this by writing your own autoloop and by using custom buttons. Honnestly, maybe you should just pick another library that ......
Read more >
Server-Side Rendering (SSR) - Vue.js
Before using SSR for your app, the first question you should ask is whether you actually need it. It mostly depends on how...
Read more >
A beginner's guide to React Server-Side Rendering (SSR)
In this lesson, we are going to talk about server-side rendering (SSR), its benefits, and its pitfalls. Then we will set up a...
Read more >
How to implement server-side rendering (SSR) in your React ...
This hook checks that if the component rendered on server-side then it will set the isLoading flag to false because the data is...
Read more >
Getting Started - BootstrapVue
Bootstrap is optimized for mobile devices first and then scales up components ... See the Vue.js Guide for full details on setting up...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found