Closed patrickxchong closed 4 years ago
Hey @patrickxchong
Thanks a lot for the nicely described issue, and please excuse the rather late response. I can see that it indeed adds two script tags, but that is also the case in a simple Vue Firebase app, see Sandbox, and I assume in all other Firebase SDK Web Apps, too.
So I think this is either expected behaviour or an issue in the Firebase JS SDK.
I myself couldn't reproduce two separate events getting triggered, could you check if that is always the case for you and if so, provide a sandbox for it?
PS:
This module does not much more than initializing analytics with firebase.analytics()
, so am leaning towards the fact that this issue is not necessarily nuxt/firebase related. But I could be wrong.
Thank you for looking into this @lupas. I agree with your analysis. I'm sorry that I didn't check whether it's something related to the Firebase JS SDK first. This has went down in my priority list but I'll look into this again on the firebase side in a few weeks. Closing this issue for now.
Version
@nuxtjs/firebase: 6.0.1 firebase: 7.15.5 nuxt: 2.13.2
Reproduction Link
https://nuxt-fire-demo.herokuapp.com/
Steps to reproduce
Open the demo app at https://nuxt-fire-demo.herokuapp.com/ and check the html there. One can see both
<script type="text/javascript" async="" src="https://www.googletagmanager.com/gtag/js?id=G-XT6PVC1D4X&l=dataLayer&cx=c"></script>
and<script src="https://www.googletagmanager.com/gtag/js?l=dataLayer" async=""></script>
Alternatively, download the Google Analytics Debugger to see that googletagmanager is initialized twice.
What is Expected?
Only the second script tag should be present. (based on https://firebase.google.com/docs/analytics/get-started)
What is actually happening?
Google Tag Manager is downloaded twice, which wastes bandwidth and also causes the the initial page_view event to be loaded twice when page_view events are sent via a middleware in Vue router. (will be happy to make a repo to reproduce it if necessary).
The double page_view events are fired shortly between each other and are recorded as two separate events in Firebase Analytics as shown below.![image](https://user-images.githubusercontent.com/20418855/86339296-00021f00-bc86-11ea-85e7-d1aae7646f9d.png)