Preview mode for GTM Server-Side tagging is not working with manual setup - google-tag-manager

I'm trying to migrate my Google Tag Manager to the Server-Side version. The workflow is actually working, the client container sends data to the server container and finally I see the tracking arriving in GA4. What is not working is the Preview server.
My Server-Side and its Preview are deployed as distinct deployments in a K8s on premises.
I have 1 ingress for each of those, and they expose respectively analytics.mydomain.com and preview.mydomain.com. Sending an HTTP request to /healhz on both of these domains return OK.
Now, when I hit the preview button on the client container menu in my browser
I can successfully load the Preview dashboard
But if I reload the page I'm tracking, I don't see any new events collected.
Moreover, if I use the "Send request manually" option using this curl
curl -H 'x-gtm-server-preview: ZW52LTN8X1VtScensoredDYxN2M4MDkyMzU3ODRhYzYxOWM==' 'https://preview.mydomain.com/g/collect?v=2&en=page_view&tid=G-1234&cid=123.456&dl=https%3A%2F%2Fexample.com%2F'
The response I got is Not Found.
What could possibly be the issue here? I also tried to deploy it outside K8s in a simple docker container but I had the same problem, It won't load events and will always respond Not Found.

Related

Google Tag Manager server container - API to monitor the quick preview?

We have setup Google Tag Manager server containers and as part of our testing, we'd like to be able to monitor what is coming into the quick preview.
Is there an API that will essentially let me monitor what is going into the quick_preview whilst our interaction tests are triggering the events?

Workbox Google Analytics doesn't work log events to resent later

I'm trying to implement the Google Analytics's Workbox Plugin on my application, which works most of the time offline. I used the webpack plugin as well to generate the service worker (SW). I used the method GenerateSW({offlineGoogleAnalytics: true}). But, unfortunately, after the SW be registered it didn't created an database for the workbox background sync, neither a table for the request (as seeing on this demo). On my application the SW is active and running but it doens't make requests, neither setup the indexDB. I'm using and local version of the gtag.js and it works as expected when the application is online, the events are logged on Analytics real time dashboard. But offline the requests aren't saved to be resent later. What I missed for this feature to work?

Firebase Hosting returning 500 internal error for Googlebot user-agent when using Google Chrome's "network conditions" tab?

I've got the following set up on my Firebase web app (it's a Single Page App built with React):
I'm doing SSR for robots user agents, so they get full rendered HTML and no Javascript
Users get the empty HTML and get the Javascript to run the app.
firebase.json
"rewrites": [{
"source": "/**",
"function": "ssrApp"
}]
Basically every request should go into my ssrApp function, that will detect robot crawlers user-agents and decide wheter it will respond with the SSR version for the robots, or the JS version for the regular users.
It is working as intended. Google is indexing my pages, and I always log some info about the user agents from my ssrApp function. For example, when I'm sharing an URL on Whatsapp, I can see Whatsapp crawler on my logs from Firebase Console (see below):
But the weird thing is that I'm not being able to mimick Googlebot using Chrome's Network Conditions tab:
When I try to access my site by using Googlebot's user agent I get a 500 - Internal error
And my ssrApp functions isn't even triggered, since NOTHING is logged out from it.
Is this a Firebase Hosting built-in protection to avoid fake Googlebots? What could be happening?
NOTE: I'm trying to mimick Googlebot's user agent because I want to inspect the SSR version of my app in production. I know that there are other ways to do that (including some Google Search Console tools), but I thought that this would work.
Could you check that your pages are still in the Google index? I have the exact same experience and 80% of my pages are now gone...
When I look up a page in Google Search Console https://search.google.com/search-console it indicates there was an issue during the last crawl. When I "Test it Live" it spins and reports the error 500 as well and asks to "try again later"...
I had a related issue, so I hope this could help anyone who encounters what I did:
I got the 500 - Internal error response for paths that were routed to a Cloud Run container when serving a GoogeBot user agent. As it happens, if the Firebase Hosting CDN happened to have a cached response for the path, it would successfully serve the cached response, but if it didn't have a cached response, then the request would not reach the Cloud Run container, it would fail at the Firebase Hosting CDN with 500 - Internal error.
It turns out that the Firebase Hosting CDN secretly probes and respects any robots.txt that is served by the Cloud Run container itself (not the Hosting site). My Cloud Run container served a robots.txt which disallowed all access to bots.
Seemingly, when the Hosting CDN attempts to serve a request from a bot from a path that is routed to a Cloud Run container, it will first probe any /robots.txt that is accessible at the root of that container itself, and then refuse to send the request to the container if disallowed by the rules therein.
Removing/adjusting the robots.txt file on the Cloud Run container itself immediately resolved the issue for me.

How to get API URL using chrome/fiddler dev tool

I have a get API call from my asp.net mvc controller using HTTP client. API returns json data and also my controller returns json data. In network tab in chrome dev tool I can get the details of my controller call and the data but I am not getting any information about that API call.
Is it possible to inspect/ track API call details using chrome or fiddler? If yes how? Or is there any other tool that will intercept those call also.
The network tab in Chrome tracks all traffic to and from the client.
You will see all of the calls sent from the server to the browser. This includes images, css, javascript, etc. However, it also shows the result of ajax calls.
For an example, go to This page and open Chrome Developer Tools. Then go to the network tab. Then simply click on the demo button and you will see the call pop up.

Tracking direct file downloads with Google Analytics and Varnish proxy

I am using Google Analytics and I want to track direct file downloads (when someone hits myserver.com/file.pdf directly). Obviously Google Analytics won't track this if it's set up with client-side javascript.
I am also using Varnish proxy which means my server doesn't necessarily even see the request if Varnish responds with a cached copy of file.pdf - so I assume that giving GA my server logs won't work nor will custom PHP on my server that runs on every file request.
What is the best way of incorporating file downloads into Google Analytics in this case?
only option i could foresee it use the varnishncsa log file to track the requests to these files, and then using the GA measurement protocol pass them over to GA. That would be a viable route to go.

Resources