-
Google Analytics: gtag log entries not being sent to server
Hey, I’ve got some issues with using GA4 gtag and not GTM. I’m calling
gtag()
and everything’s getting piled into thedatalayer
, but nope, it’s not reaching the Google Analytics server.So, I’ve put the code snippet in the HEAD of my page and it’s running fine. I’ve done the
gtag('js', ...)
andgtag('config', ...)
thing as suggested. I see those popping up in thedatalayer
. Even thegtm.dom
,gtm.load
, andgtm.scrollDepth
entries are there as they were added automatically.The same thing with adding an event like
gtag('event', 'some event')
– it’s there in the datalayer pile. But, that’s where the story stops. These items in datalayer are just not taking the flight to the GA server. There’s no traffic seen to the GA server in Chrome’s developer network view and the datalayer is not getting cleaned out.No errors on the console either.
Now, I’m sure my GA tag is working as it should because logging events with the gtag SDK is working perfectly well. I see the events in GA. But hey, I want the full gtag thing to work too.
Anyway, here’s how I’m logging events using the gtag SDK:
fetch(
https://www.google-analytics.com/mp/collect?measurement_id=<span class="hljs-subst">${GATag}</span>&api_secret=<span class="hljs-subst">${ApiSecret}</span>
, { body: JSON.stringify({ client_id: ClientId, events: [gaEvent], user_id: _userId }), method: 'POST', });So, just wondering, do I need to do something specific to get gtag to send the data from dataLayer? Or maybe some tips on figuring this out? This is getting a little frustrating!
Log in to reply.