April 15, 2020
Google Tag Manager 404 error (gtm.js 404)
Updated: April 15th, 2020. So you’ve added a Google Tag Manager snippet to a website (by carefully following the instructions). Website’s developer contacts you and says that Google Tag Manager snippet generates errors (gtm.js 404) and keeps littering his error log. Well, there’s a simple solution for 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 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 your GTM interface, click the Leave Preview Mode link in the Orange notification banner.
And then click the Preview button once again.
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 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 a #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.