June 15, 2021
Google Tag Manager 404 error (gtm.js 404)
Updated: June 15th, 2021. So you’ve added a Google Tag Manager snippet to a website (by carefully following the instructions). The website’s developer contacts you and says that the Google Tag Manager snippet generates errors (gtm.js 404) and keeps littering his error log. Well, there’s a simple solution to this issue.
404 not found for GET: GET http://www.googletagmanager.com/gtm.js?id=GTM-XXXXX
“http response code indicates tag failed to fire: status 404. this could be due to an empty or un-published container”
Both of these errors are caused by the same issue.
The solution to gtm.js 404 error
The problem lies within Google Tag Manager itself. Your browser is requesting data from Google’s servers although that container is still not published yet, thus no data will be returned. The solution here is to publish the Google Tag Manager container once you create it.
Always complete the following actions when you plan tracking of the new website with GTM:
- Create a new container in GTM.
- Publish it (with default settings).
- Install GTM to your website according to instructions (or ask a developer to do it).
- If there’s no gtm.js 404 error – go ahead and start setting up your marketing tags.
If publishing did not help
If the aforementioned solution did not help, try disabling your GTM preview mode and enable it again. In browser, close the website where you have enabled the preview mode and also close the window/tab of tagassistant.google.com (GTM’s preview mode).
Then click the Preview button once again in GTM’s interface.
Then refresh the page where you saw that gtm.js 404 error and see if it still persists.
Every time you set up a new Google Tag Manager container, publish it (even though it’s totally empty). Otherwise, the response from Google will return a 404 not found error. This isn’t a critical error but might cause a little mess in developers’ error logs. This is a common rookie mistake which is #2 on my list of most common Google Tag Manager mistakes. Make sure you check the full list.
If you have any other questions related to Google Tag Manager, feel free to post a comment or contact me via social media accounts. Also, consider subscribing to my newsletter for more relevant GTM or Google Analytics tips and guides.