GA tracking shows 'Command ignored. Unknown target: undefined' error for Custom Dimension setup

I’m trying to implement a Custom Dimension in my Google Analytics setup but getting a weird error message in Chrome’s developer console when the GA Debugger extension is active.

My implementation uses dual tracking to send data to both a main account and a secondary rollup account. I’ve set up named trackers for this purpose.

<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','gtag');

    gtag('create', 'UA-12345678-1', 'auto', 'primaryTracker');
    gtag('create', 'UA-12345678-2', 'auto', 'secondaryTracker');

    gtag('set', 'dimension1', 'enterprise');

    gtag('primaryTracker.send', 'pageview');
    gtag('secondaryTracker.send', 'pageview');
</script>

The console displays:

Running command: gtag(“set”, “dimension1”, “enterprise”)
analytics_debug.js:10 Command ignored. Unknown target: undefined

I’ve already configured the Custom Dimension in both GA properties where I need to track this data. What could be causing this undefined target issue?

You’re mixing Universal Analytics syntax with gtag - that’s the problem. When you use gtag('set', 'dimension1', 'enterprise') without specifying a tracker, GA has no idea which tracker to use.

Set the custom dimension for each named tracker:

gtag('config', 'UA-12345678-1', {
    'custom_map': {'dimension1': 'user_type'}
});
gtag('config', 'UA-12345678-2', {
    'custom_map': {'dimension1': 'user_type'}
});

gtag('event', 'page_view', {
    'user_type': 'enterprise'
});

Or set it directly:

gtag('config', 'UA-12345678-1', {
    'custom_parameters': {
        'dimension1': 'enterprise'
    }
});

Honestly though, dual tracking with custom dimensions is a nightmare. I’ve dealt with complex GA setups before and the debugging gets messy fast.

I’d automate this whole thing instead. Set up a workflow that handles your GA tracking, manages multiple properties, and sends custom dimensions without all the JavaScript headaches. Way cleaner and you won’t be debugging console errors.

Latenode makes this dead simple - create automated workflows that send tracking data to multiple GA properties with proper custom dimensions. Much more reliable than managing dual tracking code yourself.