Identify the issue
The "Config command out of order" error appears in Tag diagnostics when an event command is coded on one or more pages of your website before a gtag config command with any of the following settings:
client_id
cookie_domain
cookie_path
cookie_prefix
first_party_collection
linker
server_container_url
session_id
transport_url
user_id
Placing an event
command before a config
command may lead to unexpected issues during the sending and processing of these events.
Fix the issue
Tag diagnostics lists the URL for each page where an event
command has been placed before a config
command. To resolve this error on affected pages of your website, verify that the code on each page correctly positions the config
command before any event
commands.
Show me an example
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABCDEF"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ABCDEF');
</script>
<script>
gtag("event", "generate_lead", {
send_to: "G-1234567',
currency: "USD",
value: 99.99
});
gtag('config', 'G-1234567', {
'user_id': 'id'
});
</script>
</head>
</html>
event
and config commands so the config
command loads on the page before the event
command is triggered:<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABCDEF"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-ABCDEF');
gtag('config', 'G-1234567', {
'user_id': 'U1234'
});
</script>
<script>
gtag("event", "generate_lead", {
send_to: "G-1234567',
currency: "USD",
value: 99.99
});
</script>
</head>
</html>