Skip to content
Adrythm

ReferenceTracking error

Missing gtag config command

The Google tag's configuration command is missing or wrong on the page, so automatic events are not measured. Google's fix is to place the configuration code immediately after the opening head tag on every page. Check for a second copy from a website builder or plugin, since two copies can double count page views. Then confirm in Tag Assistant that the command fires.

At a glance

Where it shows
The Diagnostics tab in the Google tag settings, under Tag quality.
What stops
Automatic events, the page views and clicks Google measures without a custom event.
How serious
Medium. Reports lose the automatic events, and any event that depends on the configuration reads low or empty.

What it means

The Google tag's configuration command tells the tag which measurement product to send to and which page it is on. Google's message says that command is incorrect or missing, so automatic events may not be measured. The tag can load and still fail to send these events.

The fix is about where the code sits on the page, not about the Tag Manager container. Google's page places it immediately after the opening head tag, on every page.

What actually triggers it

  1. Configuration code lower in the page

    The configuration code sits after other scripts or inside a section that loads late. Google's fix moves it up to sit right after the opening head tag, so the code should move, not be copied again.

  2. A second copy from a website builder or plugin

    Not on Google's help page

    A builder or plugin ships its own gtag code alongside a copy from the container or the site's head. A builder's copy can double count page views, so decide which copy stays before adding another.

  3. Configuration dropped in a theme edit

    Not on Google's help page

    A theme or template change replaces the head section and drops the code. Nothing errors on the page, so the message is the first sign.

  4. The loader stayed and the config line went

    Not on Google's help page

    The Google tag is two pieces: a script that loads gtag.js with the tag ID in its address, and a short inline script that ends in gtag('config', 'G-...'). An editor or a cookie plugin that rewrites inline scripts can keep the first and lose the second, so the network panel shows gtag.js loading and Tag Assistant still finds no configuration.

  5. Config called before gtag exists

    Not on Google's help page

    A config line moved into its own script above the inline snippet runs before the gtag function is defined. The browser console then shows gtag is not defined, and the command never reaches the data layer.

Worked examples

Flagged
After a theme update, a dentist's site source shows the gtag.js loader for G-ABC123 and an inline script with window.dataLayer, function gtag() and gtag('js', new Date()); and nothing after it.
Passes
The missing line gtag('config', 'G-ABC123'); is put back as the last line of that same inline script, and the whole snippet sits right after the opening head tag.

gtag('js') only starts the clock. The config command is what names the tag ID and sends the page view, so without it the tag loads and measures nothing automatic.

Flagged
A developer moves the config into a separate script at the top of the head, above the Google snippet, to make it run first. The console shows Uncaught ReferenceError: gtag is not defined.
Passes
The config line goes back inside the snippet, after function gtag(){dataLayer.push(arguments);} is defined. Running first is the snippet's job, which is why Google places the whole of it right after the opening head tag.

A command can only be queued once the gtag function exists. Called earlier, it throws and is lost, and nothing on the page looks broken.

Flagged
A site loads its tags only through Tag Manager. The diagnostic appears, and someone pastes a full gtag snippet into the theme head as the fix.
Passes
The pasted snippet comes out. In the container, the Google tag with the right tag ID is set to fire on Initialization - All Pages, and the container is published.

In a container, the Google tag template sends the configuration itself, so there is no config line in the page source to move. A pasted snippet beside a container tag for the same ID is the double count the builder case warns about.

Fix it in this order

  1. Open the Diagnostics tab in the Google tag settings and read the Missing gtag config command message.
  2. View the page source of one affected page and find the Google tag. Check whether it sits directly after the opening head tag.
  3. Move the configuration code so it sits immediately after the opening head tag. Then remove any second copy from a builder or plugin that you do not need. If the builder's own copy has to stay and page views double in Google Analytics DebugView, set send_page_view to false on the Google tag.
  4. Publish the change to the live site, then reload the page.
  5. Confirm in Tag Assistant that the configuration command fires on the page, then check the Diagnostics tab again.

If the message stays with one copy on the page, the template for that page type is probably the cause. Check the other page types on the site before changing the code again.

Lead and call tracking is one of the things we sell, and it goes in before any ad budget is spent. A status like “Missing gtag config command” is the kind of problem we fix as part of it.

Often confused with

  • Missing Google tags

    Event tags with no base Google tag in the container. Here the base tag is present and its configuration is what fails, so the container is not the place to fix it.

  • Missing conversion linker

    A Google Ads or Floodlight tag exists, but the container has no conversion linker. That needs a container change, not code moved in the head.

A 30-second check in the browser console

Open the page, open the browser's developer tools and run dataLayer.filter(e => e[0] === 'config').map(e => e[1]) in the console. Every gtag command is pushed to the data layer, so the answer lists each tag ID that received a config command on that page.

An empty list on a page that loads gtag.js is this message's cause. A list with an ID other than the one in the diagnostic (an old Universal Analytics UA- ID, or another property's G- ID) means the config is there but for the wrong tag. The same ID twice means two copies are configuring it, the double count case. If dataLayer itself is undefined, the inline snippet never ran on that page.

Which fix for which site

A hand-coded or theme-edited site: put the full snippet, loader and config together, right after the opening head tag in the shared template, so every page type gets it. A site on a builder with a Google tag field: use the field and delete any pasted copy. A site on Tag Manager: fix the Google tag in the container and keep gtag code out of the page. Pick one route per tag ID.

After the change, run the console check on two or three page types, not only the home page, since a template the change missed is the usual reason the message stays.

Still have a question this page did not answer?

Ask it on a call. Thirty minutes, a straight answer, and no follow-up sequence if you decide not to work with us.