147

Google Tag Manager told me to put this underneath the opening body tag.

<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->

Now I'm getting this 404 not found for GET:

GET http://www.googletagmanager.com/gtm.js?id=GTM-XXXXXX

I implemented the code last night. Does this just take time or is this something that needs to be fixed? If the latter, how would I fix it?

3
  • 33
    Have you published at least the first version of you container?
    – Sundrique
    Commented Mar 25, 2015 at 5:36
  • @Sundrique I'm not sure. How can I check?
    – J82
    Commented Mar 25, 2015 at 8:36
  • 14
    Go to Container -> Overview, and click blue "Publish" button in the top right corner. Thank click "Create version and publish" in a popup.
    – Sundrique
    Commented Mar 25, 2015 at 8:49

9 Answers 9

261

You need to publish a version of your container. If it is not published, the request will return a 404 error.

To publish your current workspace:

  1. Click Submit at the top right hand side of the screen. The Submit Changes screen will appear, with options to publish the container and save a version of your container.
  2. Select Publish and Create Version if it is not already selected.
  3. Review the Workspace Changes section to see if your configuration appears as you expect.
  4. Enter a Version Name and Version Description.
  5. If you have Tag Manager configured to use multiple environments, use the Publish to Environment section to select which environment you'd like to publish to.
  6. Click Publish.
4
  • 2
    Note that you may not see the options for publishing if your user does not have "Publish" rights on the container - even if you're an Admin.
    – StuartQ
    Commented Feb 16, 2017 at 11:00
  • After making changes in the workspace, you will need to go back to your environments and publish each one to the appropriate version.
    – mbunch
    Commented Jan 2, 2018 at 21:15
  • This is the correct solution but for cases when users already have the container published, the reason for the 404 is that preview mode expired. You can fix this by disabling the preview mode. So there are 2 causes for the 404 error: 1. Unpublished container 2. Expired preview mode in GTM Check analyticshelp.io/blog/… for more details on this Commented Apr 18, 2020 at 15:11
  • As of June 2021 new GTM containers automatically create a published (empty) version to avoid this problem. Obviously you still need to publish again to see any changes you make. Commented Aug 11, 2021 at 21:22
10

I had the same issue even after publishing and got it fixed by simply deleting the subdomain "www" from the tag manager domain "https://googletagmanager.com" instead of "https://www.googletagmanager.com"

Seems the problem is that the DNS is blocking www. or the subdomain doesn't reroute properly to our region!

4
  • 1
    Wasn't expecting this to be the solution but it's exactly what I needed!
    – adamduren
    Commented Jul 18, 2019 at 1:57
  • This solved the 404 error, but then the "Preview and Debug" mode didn't work. I restored the www. subdomain and curiously everything works as expected. Maybe we just have to wait until the changes get propagated... Commented Mar 12, 2020 at 10:54
  • Interesting, this was the case for me as well. Definitely region based, as my colleagues in the UK are not affected. Do you think it's safe to remove the www. bit in the GTM snippets? Commented Jan 13, 2021 at 9:32
  • 1
    @VojtaHejda can't guarantee but have been using it without the www. for 2.5 years and didn't have an issue
    – Kareem
    Commented Jan 14, 2021 at 13:41
9

My issue was that had AdBlock enabled.

0
1

In my case it helped when I leave Preview and launch it again. As I figured out my preview was somehow "outdated".

0

As of this writing, you don't need to publish the container to fix the Error 404 when you first create the container. You can just do a preview and the error 404 should be gone.

0

Once you done any changes on Google tag manager make sure you publish it. if you are not publishing changes on google tag manager then this issue will occur.

0

Just to share my encounter of a rather similar problem.

I noticed the optimize.js script in the GTM was hitting 404 on the console and the GA stopped tracking visits for a while. The optimize.js is a tag from Google and for no apparent reason, it stopped tracking. And, it was a dependent tag for the GA tag to run. enter image description here

After I disabled the optimize.js tag and removed it as the dependent tag on the GA tag, the GA starts to track again and I no longer get the 404 error on GTM.

Just thought it might be helpful info.

Cheers!

0

GTM can return a 404 when trying to load a container that isn't enabled for debugging. Debugging can be enabled by checking the Enable Debugging by Default checkbox under Admin > Environments > Actions > Edit Settings > Environment Configuration. That fixed it in my case.

-1

You must publish the container once you create it. It's doesn't matter the container is empty, just publish it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.