If Google Tag Manager stops your site loading or returns a 403 error, ModSecurity is often blocking the Google Tag Manager noscript code. You can fix this by disabling the specific rule for your domain, without turning off the firewall for your whole site.

Google Tag Manager sometimes uses a small hidden iFrame as a fallback when JavaScript cannot run. ModSecurity (a web application firewall, or WAF, that filters requests and responses on your server) can treat this iFrame as a possible threat and block it. Your site may then slow down or show an error.

Check the error log for the rule ID

Your error log shows which rule blocked the page. Look for a line that contains ModSecurity: Access denied, then note the rule ID shown in the [id "..."] part of the message.

A block with an ID such as [id "981000"] is an example. Your ID may be different. Rule IDs can change between versions of the rule set, so always use the ID from your own log.

Messages that start with IM360 WAF come from Imunify360, the security suite on Hostking servers. These are handled differently (see the Troubleshooting section below).

Customers on shared hosting usually cannot open the log files directly. Use the ModSecurity tools in your control panel instead, as described below.

Disable the rule for your domain

Disable only the rule that blocked your page, and only for the affected domain. This keeps the rest of your protection in place.

cPanel

  1. Log in to cPanel.
  2. In the Security section, click ModSecurity.
  3. Find the domain you need in the list and click Rules List.
  4. Find the rule ID from your error log.
  5. Click Disable next to that rule.
  6. Reload your page and check that it loads.

DirectAdmin

  1. Log in to DirectAdmin.
  2. Open the ModSecurity section.
  3. Open the tab for disabling rules. This may be called Status & Disabled Rules, or you may find it on the main ModSecurity page.
  4. In the field labelled ID or Rule ID, enter the rule ID from your error log.
  5. Click Disable Rule or Save.
  6. Wait about 1 minute for the change to apply, then reload your page.

Menu names can vary by plan. If you cannot find these options, check your welcome email or the client area at my.hostking.host.

Update your Google Tag Manager code

If you can still not get the page to load, you can change the Google Tag Manager noscript code. Replace GTM-XXXXXX with your own container ID from Google Tag Manager.

The standard code looks like this:

<!-- 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 -->

In the noscript iFrame, change the height and width values and the hidden styling to a class, as in this example:

<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXXX"
height="21" width="21" class="noDisplay"></iframe></noscript>

Then add this rule to your site's stylesheet:

.noDisplay {
display:none;
visibility:hidden;
}

Removing the noscript section entirely also stops the block, but this removes the fallback for visitors without JavaScript.

Troubleshooting

The page still fails after you disable the rule. Wait a minute, then clear your browser cache and reload. Check that you disabled the rule for the correct domain.

The error message starts with IM360 WAF. This rule belongs to Imunify360. Check your welcome email or the client area at my.hostking.host for how to manage Imunify360 rules on your plan.

Your site is still slow after the fix. Slow loading can have other causes. Check that your images are compressed, and check how many external requests your pages make. You can test this with a site speed tool.

You need help. Use live chat on the Hostking website or open a support ticket from the client area at my.hostking.host. Include the rule ID from your error log, but do not post your full log in public.

Do not turn ModSecurity off for your whole account or disable rules for every site on the server. This removes protection from your site and from others on the server.

Was this answer helpful? 1 Users Found This Useful (1 Votes)