Skip to content

Getting error "Cannot read property 'containerId' of undefined" when using with GTM #4856

Closed
@alex-mironov

Description

@alex-mironov

I've integrated Firebase into the react application where GTM is already used. When I'm trying to log some event for the first time it crashes:

import firebase from 'firebase/app'
  
firebase.initializeApp({
  apiKey: '...',
  authDomain: '...',
  databaseURL: '...',
  projectId: '...',
  storageBucket: '...',
  messagingSenderId: '...',
  appId: '...',
  measurementId: '...',
})
...
  firebase.analytics().logEvent('custom_event', {
    login: 'login',
  })

The error I see in the console at the moment the above event is sent:

gtm.js?id=GTM-M4SMHQD&gtm_auth=&gtm_preview=&gtm_cookies_win=x:292 Uncaught TypeError: Cannot read property 'containerId' of undefined
    at Pl (gtm.js?id=GTM-M4SMHQD&gtm_auth=&gtm_preview=&gtm_cookies_win=x:292)
    at Hl.aa.flush (gtm.js?id=GTM-M4SM...&gtm_auth=&gtm_preview=&gtm_cookies_win=x:299)
    at Hl.aa.push (gtm.js?id=GTM-M4SM...&gtm_auth=&gtm_preview=&gtm_cookies_win=x:297)
    at Kl (js?l=dataLayer&id=G-ERXSK...:175)
    at config (js?l=dataLayer&id=G-ERXSK...:186)
    at Tm (js?l=dataLayer&id=G-ERXSKR...:195)
    at Um (js?l=dataLayer&id=G-ERXSK...:195)

All the subsequent calls of logEvent work just fine.

And here is how I'm using GTM:

import TagManager from 'react-gtm-module'

TagManager.initialize({
  gtmId: '...',
})
    "firebase": "^8.4.1",
    "react-gtm-module": "^2.0.11",

I would appreciate any help on that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions